-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example datetime + tz where FoundDateTimeList
is empty
#34
Comments
The corresponding test for this is here: Line 588 in ea9dc5a
Here is a simplified example: let local_time_types = vec![LocalTimeType::new(0, false, None)?, LocalTimeType::new(3600, false, None)?];
let time_zone = TimeZone::new(vec![Transition::new(0, 1), Transition::new(86400, 1)], local_time_types.clone(), vec![], None)?;
let time_zone_ref = time_zone.as_ref();
let result1 = DateTime::find(1969, 12, 31, 12, 0, 0, 0, time_zone_ref)?;
let result2 = DateTime::find(1970, 1, 1, 12, 0, 0, 0, time_zone_ref)?;
let result3 = DateTime::find(1970, 1, 2, 12, 0, 0, 0, time_zone_ref)?;
assert_eq!(result1.into_inner(), [FoundDateTimeKind::Normal(DateTime::new(1969, 12, 31, 12, 0, 0, 0, local_time_types[0])?)]);
assert_eq!(result2.into_inner(), [FoundDateTimeKind::Normal(DateTime::new(1970, 1, 1, 12, 0, 0, 0, local_time_types[1])?)]);
assert_eq!(result3.into_inner(), []); The assert!(matches!(
time_zone_ref.find_local_time_type(2 * 86400),
Err(FindLocalTimeTypeError("no local time type is available for the specified timestamp"))
)); This situation can happen when using a TZif v1 file, which cannot contain a footer with an extra rule definition. If you are using the last version of the Time Zone Database, all TZif v1 files have been replaced by TZif v2 or v3 files, so this error should be uncommon. |
Thank you! |
Handle a rare error condition in `tzrs::Time::new` which can occur when using older TZif v1 files in older versions of the Time Zone Database. Thanks to @x-hgg-x for providing an explainer on the failure scenario and a test case, which has been replicated in `spinoso-time`. See: - x-hgg-x/tz-rs#34 - x-hgg-x/tz-rs#34 (comment)
Thanks @x-hgg-x for the test case! I've replicated this error condition in a |
Handle a rare error condition in `tzrs::Time::new` which can occur when using older TZif v1 files in older versions of the Time Zone Database. Thanks to @x-hgg-x for providing an explainer on the failure scenario and a test case, which has been replicated in `spinoso-time`. See: - x-hgg-x/tz-rs#34 - x-hgg-x/tz-rs#34 (comment)
I currently have an integration with
tz-rs
that looks like this:https://github.com/artichoke/artichoke/blob/ae40b16294d699ea9e9df459785bd9578372b33a/spinoso-time/src/time/tzrs/mod.rs#L149-L166
I took a peek at the source and it looks like
FoundDateTimeList
is implemented with an innerVec
and the calls toearliest()
andlatest()
essentially boil down toVec::first
andVec::last
, but I'm wondering: can thisexpect
ever panic?I'd love an example timespec + TZ where in practice that this found date time list is empty so I can add a test that makes this
expect
panic and enforce that this case is handled. Do you happen to know of one?The text was updated successfully, but these errors were encountered: