baml.time._wrap_into_day

(internal) Reduces `total_ns` to nanoseconds-since-midnight in `[0, 24h)`, re-establishing `PlainTime._nanoseconds`'s invariant after arithmetic.

Reference version

Signature

function baml.time._wrap_into_day(total_ns: bigint) -> int throws never

(internal) Reduces total_ns to nanoseconds-since-midnight in [0, 24h), re-establishing PlainTime._nanoseconds's invariant after arithmetic.

Written ((n % day) + day) % day rather than n % day because % keeps the sign of its left operand: a negative total_ns would otherwise stay negative.

Returns

The wrapped count, always in [0, 24h) and therefore always an int.

Source:<builtin>/baml/ns_time/plaintime.bamlbytes 10009–10448