-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement PartialZonedDateTime
and from_partial
and from_str
for ZonedDateTime
#115
Conversation
d5b3f3f
to
b5140cc
Compare
b5140cc
to
1c6a8cd
Compare
pub trait TzProvider { | ||
fn check_identifier(&self, identifier: &str) -> bool; | ||
|
||
fn get_named_tz_epoch_nanoseconds( | ||
&self, | ||
identifier: &str, | ||
iso_datetime: IsoDateTime, | ||
) -> TemporalResult<Vec<i128>>; | ||
) -> TemporalResult<Vec<EpochNanoseconds>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed when rebasing this PR that EpochNanoseconds
can (and probably should) be used in more places throughout temporal_rs
then I had initially thought. I added some of that work to this PR due to it somewhat being in the scope of work here. For the rest though, I'm thinking it would be best to open up an issue for it and continue looking into using EpochNanoseconds
in more places for a subsequent PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! Could be a nice first issue for a future contributor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened an issue for it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
millisecond: f64, | ||
microsecond: f64, | ||
nanosecond: f64, | ||
hour: i64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update the comment above that says an f64 is needed here....
src/components/zoneddatetime.rs
Outdated
#[cfg(feature = "experimental")] | ||
use crate::components::tz::TZ_PROVIDER; | ||
#[cfg(feature = "experimental")] | ||
use std::ops::Deref; | ||
|
||
/// A struct representing a partial `ZonedDateTime`. | ||
pub struct PartialZonedDateTime { | ||
/// The `PartialDate` portion of a `PartialDateTime` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment supposed to say "The PartialDate
portion of a PartialZonedDateTime
or the PartialDateTime
is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opps, forgot to type Zoned 😂
fccd459
to
5a0b4fd
Compare
This PR is dependent on #115 and will need a rebase once that PR is merged. This continues to build out methods that `ZonedDateTime` needs for accessor methods. Overall the features implemented are: - All calendar accessor methods - An implementation of `HoursInDay` method
Posting this early as a draft as the logic was pretty dense to work through.
This PR still needs some baseline tests added for the methods before it's ready to not be a draft.Update:
Tests have been added! There's also a bug fix in
tzdb.rs
.Overall, this implements the core logic in temporal_rs for supporting
ToTemporalZonedDateTime
and should unblock implementingTemporal.ZonedDateTime.from
in Boa.Overview:
PartialZonedDateTime
from_partial
andfrom_partial_with_provider
from_str
andfrom_str_with_provider
get_local_record
IsoDateTime::balance
away from using f64.