Module convert
Expand description
Exact numeric conversions for calendar quantities.
Date arithmetic hands back i64 day counts and u32 year/month/day
components; day-count fractions and schedule maths need them as f64 or
i32. Every such conversion in this crate is provably exact, but written as
a bare cast it is indistinguishable from one that is not โ so the casts live
here, once, with the bound that makes them safe stated alongside.
Functionsยง
- count_
to_ ๐f64 - A count of periods as a float โ a fixed leg has tens of periods, never more than a mantissa holds, so the widening is exact.
- count_
to_ ๐i64 - Converts a count of elements to
i64. - days_
to_ ๐f64 - Converts a whole-day count to
f64. - days_
to_ ๐index - Converts a non-negative day count to
u32, for indexing a per-day table. - days_
to_ ๐offset - Converts a non-negative day count to
u64, forchronoโsDays. - months_
to_ ๐offset - Converts a non-negative span in months to
u32, forchronoโsMonths. - seconds_
to_ ๐f64 - Converts an elapsed-seconds count to
f64. - week_
index ๐ - Converts a non-negative weekday offset to an index into a week mask.
- ymd_
from_ ๐i32 - Converts a year, month, or day-of-month component computed in
i32back tou32. - ymd_
to_ ๐i32 - Converts a year, month, or day-of-month component โ or a span in months โ
to
i32.