MCPcopy Index your code
hub / github.com/Effect-TS/effect / parts

Function parts

packages/effect/src/Duration.ts:769–804  ·  view source on GitHub ↗
(self: DurationInput)

Source from the content-addressed store, hash-verified

767 * @category conversions
768 */
769export 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.

Callers 2

formatFunction · 0.85
unsafeFormatIsoFunction · 0.85

Calls 3

unsafeToNanosFunction · 0.85
NumberInterface · 0.85
decodeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…