birl
birl copied to clipboard
Setting time of day crashes when in a timezone that is behind UTC and it is past midnight in UTC
The test function:
pub fn birl_set_time_of_day_test() {
birl.now()
|> birl.set_time_of_day(birl.TimeOfDay(9, 30, 0, 0))
}
fails when it is past 12:00 AM UTC but before (I assume, haven't waited to test it yet) 4:00 AM UTC on a system which has a time zone of EDT(UTC-04).
On my system, birl.now()
produces Time(1714523701784880, 158400000000, Some("America/New_York"), Some(247434))
The stack trace is:
birl_set_time_of_day_test
#{function => <<"to_parts">>,gleam_error => let_assert,line => 1237,
message => <<"Assertion pattern match failed">>,module => <<"birl">>,
value => {error,nil}}
location: birl.to_parts:1237
stacktrace:
birl.to_parts
birl.set_time_of_day
I believe a time zone of (UTC-02) would crash between 12:00 AM UTC and 2:00 AM UTC, but I haven't tested it yet because it takes waiting. I believe the issue is when the date of the local time is different than the date of the UTC time, but could be wrong.
I can work around this by setting my system's time zone to either UTC or a timezone ahead of it. I am in the EDT time zone and just randomly started getting crashes after 8pm while working.
EDIT: while I was testing it further I realized converting to UTC from EDT right now (Apr 30, 8:39pm) also changes the month in the calendar date, so maybe that is the issue. I will run the test again tomorrow past 8pm and see.