Skip to content
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

Wrong output from %Z specifier when using Local::now().format() #749

Closed
s1gse9v opened this issue Jul 30, 2022 · 2 comments
Closed

Wrong output from %Z specifier when using Local::now().format() #749

s1gse9v opened this issue Jul 30, 2022 · 2 comments
Labels
API-incompatible Tracking changes that need incompatible API revisions
Milestone

Comments

@s1gse9v
Copy link

s1gse9v commented Jul 30, 2022

See below for an example:

use chrono::Local;

fn main() {
    println!("{}",Local::now().format("%z"));
    println!("{}",Local::now().format("%Z"));
}

Output:

+0200
+02:00

Expected output:

+0200
CEST

Interestingly, everything works fine when you substitute Local for Utc

@esheppa
Copy link
Collaborator

esheppa commented Jul 31, 2022

Thanks for reporting this @s1gse9v. We don't currently guarantee identical behavior to the date command, however we do use it as a guide (for example in testing the functionality of Local), but this is a difference that I hadn't realized until now and it would be nice to match the output if we can.

This should be relatively straightforward on Linux, and a little bit more involved on Windows, however it looks like your use case would need this to be properly cross platform so I'll aim for both.

Unfortunately I think the changes needed to make here would result in a change of chronos public API as currently Local uses FixedOffset and that would need to be changed for a new data type that stores the name of the timezone internally. This means that if/when this was fixed, it would be only in a 0.5 release. Alternatively we could store this as an optional field in FixedOffset but that may have unintended performance implications.

@pitdicker
Copy link
Collaborator

Closing as duplicate of #288.

@pitdicker pitdicker closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API-incompatible Tracking changes that need incompatible API revisions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants