This issue is meant more for a general discussion for what the trait should look like.
Current
pub trait TimeZoneProvider {
fn check_identifier(&self, identifier: &str) -> bool;
fn get_named_tz_epoch_nanoseconds(
&self,
identifier: &str,
local_datetime: IsoDateTime,
) -> TemporalResult<Vec<EpochNanoseconds>>;
fn get_named_tz_offset_nanoseconds(
&self,
identifier: &str,
epoch_nanoseconds: i128,
) -> TemporalResult<TimeZoneTransitionInfo>;
// TODO: implement and stabalize
fn get_named_tz_transition(
&self,
identifier: &str,
epoch_nanoseconds: i128,
direction: TransitionDirection,
) -> TemporalResult<Option<EpochNanoseconds>>;
}
There are a couple questions here.
- This doesn't allow for normalizing and fetching a time zone index, which would allow
TimeZone to be Copy.
- It's not clear that a request would require
epoch_nanoseconds as all time zone database calculations happen in seconds.
Below is some quick general thoughts on changes that could be made to address the first problem.
pub trait TimeZoneProvider {
type Index: Clone + Copy + Debug;
fn is_available_name(s: &str) -> Option<Self::Index>;
fn get_identifier(index: Self::Index) -> &str;
// other methods
}
The idea here would be to allow the index to be flexible for others usages. Although, I'd also be fine with it being a more straightforward struct like IdentifierIndex(usize) for example.
As for the second, I would propose moving the TimeZoneProvider trait away from nanoseconds in favor of seconds represented by an i64.
This issue is meant more for a general discussion for what the trait should look like.
Current
There are a couple questions here.
TimeZoneto be Copy.epoch_nanosecondsas all time zone database calculations happen in seconds.Below is some quick general thoughts on changes that could be made to address the first problem.
The idea here would be to allow the index to be flexible for others usages. Although, I'd also be fine with it being a more straightforward struct like
IdentifierIndex(usize)for example.As for the second, I would propose moving the
TimeZoneProvidertrait away from nanoseconds in favor of seconds represented by an i64.