Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Jiff should use minute precision when comparing offsets after parsing zoned datetimes #231

Closed
BurntSushi opened this issue Feb 1, 2025 · 0 comments · Fixed by #234
Closed
Labels
bug Something isn't working

Comments

@BurntSushi
Copy link
Owner

This Jiff program:

use jiff::Zoned;

fn main() -> anyhow::Result<()> {
    let zdt: Zoned =
        "1969-12-31T23:15:30-00:44:30[Africa/Monrovia]".parse()?;
    dbg!(&zdt);
    let zdt: Zoned = "1969-12-31T23:15:30-00:45[Africa/Monrovia]".parse()?;
    dbg!(&zdt);

    Ok(())
}

Has this output:

$ cargo -q r
[main.rs:6:5] &zdt = 1969-12-31T23:15:30-00:45[Africa/Monrovia]
Error: parsing "1969-12-31T23:15:30-00:45[Africa/Monrovia]" failed: datetime 1969-12-31T23:15:30 could not resolve to a timestamp since 'reject' conflict resolution was chosen, and because datetime has offset -00:45, but the time zone Africa/Monrovia for the given datetime unambiguously has offset -00:44:30

But it shouldn't error. The reason is that -00:45 as parsed in the second example doesn't match the actual internal offset of -00:44:30.

I realized Jiff had a bug here because of this Temporal issue: tc39/proposal-temporal#3079

@BurntSushi BurntSushi added the bug Something isn't working label Feb 1, 2025
BurntSushi added a commit that referenced this issue Feb 1, 2025
This new routine is like `resolve`, but permits callers to control
how and when two offsets are considered equal. This is then in turn
used by our Temporal datetime parser to permit parsing of offsets
that have been rounded to the nearest minute without rejecting them
for being unequal.

Fixes #231
BurntSushi added a commit that referenced this issue Feb 1, 2025
This new routine is like `resolve`, but permits callers to control
how and when two offsets are considered equal. This is then in turn
used by our Temporal datetime parser to permit parsing of offsets
that have been rounded to the nearest minute without rejecting them
for being unequal.

Fixes #231
BurntSushi added a commit that referenced this issue Feb 1, 2025
This new routine is like `resolve`, but permits callers to control
how and when two offsets are considered equal. This is then in turn
used by our Temporal datetime parser to permit parsing of offsets
that have been rounded to the nearest minute without rejecting them
for being unequal.

Fixes #231
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant