(self: DurationInput)
| 767 | * @category conversions |
| 768 | */ |
| 769 | export const parts = (self: DurationInput): { |
| 770 | days: number |
| 771 | hours: number |
| 772 | minutes: number |
| 773 | seconds: number |
| 774 | millis: number |
| 775 | nanos: number |
| 776 | } => { |
| 777 | const duration = decode(self) |
| 778 | if (duration.value._tag === "Infinity") { |
| 779 | return { |
| 780 | days: Infinity, |
| 781 | hours: Infinity, |
| 782 | minutes: Infinity, |
| 783 | seconds: Infinity, |
| 784 | millis: Infinity, |
| 785 | nanos: Infinity |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | const nanos = unsafeToNanos(duration) |
| 790 | const ms = nanos / bigint1e6 |
| 791 | const sec = ms / bigint1e3 |
| 792 | const min = sec / bigint60 |
| 793 | const hr = min / bigint60 |
| 794 | const days = hr / bigint24 |
| 795 | |
| 796 | return { |
| 797 | days: Number(days), |
| 798 | hours: Number(hr % bigint24), |
| 799 | minutes: Number(min % bigint60), |
| 800 | seconds: Number(sec % bigint60), |
| 801 | millis: Number(ms % bigint1e3), |
| 802 | nanos: Number(nanos % bigint1e6) |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | /** |
| 807 | * Converts a `Duration` to a human readable string. |
no test coverage detected
searching dependent graphs…