Skip to content

Conversation

@nekevss
Copy link
Member

@nekevss nekevss commented Sep 12, 2025

This is a general update to way to construct ZonedDateTime.

The first change was mostly to add a more ergonomic way to construct a ZonedDateTime from an Instant.

For instance,

Before:

let instant = Temporal::now().instant().unwrap();
let zdt = Temporal::now().zoned_date_time_iso(None);

let zdt_from_instant = ZonedDateTime::try_new(
    instant.as_i128(),
    Calendar::ISO,
    zdt.time_zone(),
).unwrap()

After:

let instant = Temporal::now().instant().unwrap();
let zdt = Temporal::now().zoned_date_time_iso(None);

let zdt_from_instant = ZonedDateTime::try_new_iso_from_instant(
    instant,
    zdt.time_zone(),
).unwrap()

The second change reorders the parameters so that time zone is first. This is so the function signatures remain relatively consistent as both provider and calendar are removed.

@nekevss nekevss requested a review from Manishearth September 12, 2025 18:09
@nekevss nekevss added the C-api Changes related to the public API label Sep 12, 2025
@nekevss nekevss merged commit 2a7b89a into main Sep 13, 2025
8 checks passed
@nekevss nekevss deleted the update-zdt-ctors branch September 14, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-api Changes related to the public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants