EncodeBigInt is the same as Encode, except that it always returns successfully and is slower.
()
| 412 | // EncodeBigInt is the same as Encode, except that it always returns |
| 413 | // successfully and is slower. |
| 414 | func (d Duration) EncodeBigInt() (sortNanos *big.Int, months int64, days int64) { |
| 415 | bigMonths := big.NewInt(d.Months) |
| 416 | bigMonths.Mul(bigMonths, big.NewInt(nanosInMonth)) |
| 417 | bigDays := big.NewInt(d.Days) |
| 418 | bigDays.Mul(bigDays, big.NewInt(nanosInDay)) |
| 419 | totalNanos := big.NewInt(d.nanos) |
| 420 | totalNanos.Add(totalNanos, bigMonths).Add(totalNanos, bigDays) |
| 421 | return totalNanos, d.Months, d.Days |
| 422 | } |
| 423 | |
| 424 | // Decode reverses the three integers returned from Encode and produces an equal |
| 425 | // Duration to the original. |