Skip to content

Move TimeZoneProvider to timezone_provider crate#526

Merged
Manishearth merged 12 commits intoboa-dev:mainfrom
Manishearth:timezone-new
Aug 28, 2025
Merged

Move TimeZoneProvider to timezone_provider crate#526
Manishearth merged 12 commits intoboa-dev:mainfrom
Manishearth:timezone-new

Conversation

@Manishearth
Copy link
Copy Markdown
Contributor

Work towards #409

This moves the TimeZoneProvider trait to the timezone_provider crate. There's a lot of stuff that gets moved as a result.

Some important things to note:

  • TimeZoneProvider now operates on its own IsoDateTime type
  • TimeZoneProvider produces UtcOffsetSeconds, not UtcOffsets
  • the utils mostly got moved to timezone_provider::utils, but it's doc(hidden).

@Manishearth Manishearth requested a review from nekevss August 27, 2025 22:33
Copy link
Copy Markdown
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall fine with the move. Especially if this is considered more of an intermediate stage.

Left a few general thoughts that I had. Nothing blocking merge. More just notes.

Comment thread Cargo.toml
log = { workspace = true, optional = true }

# tzdb feature
tzif = { workspace = true, optional = true }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice to see

pub(crate) const NS_MIN_INSTANT: i128 = -NS_MAX_INSTANT;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct EpochNanoseconds(pub i128);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: whenever I've mocked this migration, I always decided against moving this.

Not that the move wouldn't be worthwhile, but it really brings up the question of handling EpochSeconds, which may be something to add in follow-ups. EpochNanoseconds are required by the Temporal specification, but from a generic usability perspective, I'd assume that many operate in seconds.

Comment thread provider/src/lib.rs
#[cfg(feature = "experimental_tzif")]
pub mod experimental_tzif;

pub mod epoch_nanoseconds;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I've never been sure what to call this module.

EpochNanoseconds is specific to the Unix epoch. This is being reexported from a unix_time module, which also isn't that great of a name ... maybe just a unix module?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I generally consider the public API of this crate to still need more work. If you have ideas, I'd love to see them; I don't personally plan to keep cleaning up the structure of the public API.

Comment thread provider/src/provider.rs
fn get_named_tz_epoch_nanoseconds(
&self,
identifier: &str,
local_datetime: IsoDateTime,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: not the biggest fan of IsoDateTime being used here, but I'm not sure that there's a better alternative.

At least it's self contained in timezone_provider. Still might be nice if this could be somehow expressed in seconds and nanoseconds. But I'd also acknowledge that that could cause a lot of confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual use cases all use datetimes; "local seconds" is a confusing concept.

@Manishearth Manishearth merged commit 8a9eafe into boa-dev:main Aug 28, 2025
8 checks passed
@Manishearth Manishearth deleted the timezone-new branch August 28, 2025 00:09
Manishearth added a commit to Manishearth/temporal that referenced this pull request Aug 28, 2025
Work towards boa-dev#409

This moves the TimeZoneProvider trait to the timezone_provider crate.
There's a lot of stuff that gets moved as a result.

Some important things to note:

 - TimeZoneProvider now operates on its own IsoDateTime type
 - TimeZoneProvider produces UtcOffsetSeconds, not UtcOffsets
- the utils *mostly* got moved to timezone_provider::utils, but it's
doc(hidden).
Manishearth added a commit to Manishearth/temporal that referenced this pull request Aug 29, 2025
Work towards boa-dev#409

This moves the TimeZoneProvider trait to the timezone_provider crate.
There's a lot of stuff that gets moved as a result.

Some important things to note:

 - TimeZoneProvider now operates on its own IsoDateTime type
 - TimeZoneProvider produces UtcOffsetSeconds, not UtcOffsets
- the utils *mostly* got moved to timezone_provider::utils, but it's
doc(hidden).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants