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