TimeDiff adds the field key with positive duration between time t and start. If time t is not greater than start, duration will be 0. Duration format follows the same principle as Dur().
(key string, t time.Time, start time.Time)
| 805 | // If time t is not greater than start, duration will be 0. |
| 806 | // Duration format follows the same principle as Dur(). |
| 807 | func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event { |
| 808 | if e == nil { |
| 809 | return e |
| 810 | } |
| 811 | var d time.Duration |
| 812 | if t.After(start) { |
| 813 | d = t.Sub(start) |
| 814 | } |
| 815 | e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldFormat, DurationFieldInteger, FloatingPointPrecision) |
| 816 | return e |
| 817 | } |
| 818 | |
| 819 | // Any is a wrapper around Event.Interface. |
| 820 | func (e *Event) Any(key string, i interface{}) *Event { |