Conversation
nekevss
left a comment
There was a problem hiding this comment.
Looks good to me.
A couple nits, but nothing non-blocking
|
|
||
| #[cfg(feature = "tzdb")] | ||
| fn month_to_day(m: u8, leap_day: u16) -> u16 { | ||
| pub(crate) fn month_to_day(m: u8, leap_day: u16) -> u16 { |
There was a problem hiding this comment.
nit: can this be documented to be a zero base month (mainly important because the neri-schneider calculations are 1 based).
There was a problem hiding this comment.
Maybe we should be more consistent about this? I wouldn't be against basing everything on 1 instead of having mixed bases
There was a problem hiding this comment.
Nice! I'll do the cleanup in a separate PR.
| TransitionDay::NoLeap(day) => day - 1, | ||
| TransitionDay::WithLeap(day) => day, | ||
| TransitionDay::Mwd(month, week, day) => { | ||
| let days_to_month = utils::month_to_day((month - 1) as u8, leap_day); |
There was a problem hiding this comment.
nit: it may be a bit more clear for this to be renamed from month_to_day -> month_to_day_of_year.
I think I had originally written this function, and looking back I think the name lacks a bit of clarity.
There was a problem hiding this comment.
I'm planning on addressing this in a future cleanup that makes the names on the utils module a bit more consistent.
| pub(crate) fn epoch_seconds_to_day_of_week(t: i64) -> u16 { | ||
| (((t / 86_400) + 4) % 7) as u16 | ||
| pub(crate) fn epoch_seconds_to_day_of_week(t: i64) -> u8 { | ||
| ((t / 86_400) + 4).rem_euclid(7) as u8 |
Phew, that was an adventure. This also adds a test that verifies that the mwd resolution works... on the thin tzdb that jiff bundles. The local UNIX database already has the year 2028 on its transition table, so in that case it just tests that the transition is correctly fetched.