EncodeDurationAscending encodes a duration.Duration value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare will order them the same way after encoding.
(b []byte, d duration.Duration)
| 1508 | // be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare |
| 1509 | // will order them the same way after encoding. |
| 1510 | func EncodeDurationAscending(b []byte, d duration.Duration) ([]byte, error) { |
| 1511 | sortNanos, months, days, err := d.Encode() |
| 1512 | if err != nil { |
| 1513 | // TODO(dan): Handle this using d.EncodeBigInt() and the |
| 1514 | // durationBigNeg/durationBigPos markers. |
| 1515 | return b, err |
| 1516 | } |
| 1517 | b = append(b, durationMarker) |
| 1518 | b = EncodeVarintAscending(b, sortNanos) |
| 1519 | b = EncodeVarintAscending(b, months) |
| 1520 | b = EncodeVarintAscending(b, days) |
| 1521 | return b, nil |
| 1522 | } |
| 1523 | |
| 1524 | // EncodeDurationDescending is the descending version of EncodeDurationAscending. |
| 1525 | func EncodeDurationDescending(b []byte, d duration.Duration) ([]byte, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…