AppendDuration encodes and adds a duration to the dst byte array. useInt field indicates whether to store the duration as seconds (integer) or as seconds+nanoseconds (float).
(dst []byte, d time.Duration, unit time.Duration, format string, useInt bool, unused int)
| 75 | // useInt field indicates whether to store the duration as seconds (integer) or |
| 76 | // as seconds+nanoseconds (float). |
| 77 | func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, format string, useInt bool, unused int) []byte { |
| 78 | if useInt { |
| 79 | return e.AppendInt64(dst, int64(d/unit)) |
| 80 | } |
| 81 | switch format { |
| 82 | case durationFormatFloat: |
| 83 | return e.AppendFloat64(dst, float64(d)/float64(unit), unused) |
| 84 | case durationFormatInt: |
| 85 | return e.AppendInt64(dst, int64(d/unit)) |
| 86 | case durationFormatString: |
| 87 | return e.AppendString(dst, d.String()) |
| 88 | } |
| 89 | return e.AppendFloat64(dst, float64(d)/float64(unit), unused) |
| 90 | } |
| 91 | |
| 92 | // AppendDurations encodes and adds an array of durations to the dst byte array. |
| 93 | // useInt field indicates whether to store the duration as seconds (integer) or |