this post was submitted on 22 Jul 2024
80 points (97.6% liked)

Rust

5949 readers
2 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 3 months ago (1 children)

OK, fair enough. What should it say instead? Just omit the mention of DateTime<Local>? I used it because it's literally the only way to derive(Deserialize) in Chrono in a way that gives you DST aware arithmetic on the result without getting time zone information via some out-of-band mechanism.

[–] [email protected] 1 points 3 months ago (1 children)

Actually, I may have been too finicky about this myself.

Since I often write my own wrapping serialization code for use with non-serde formats, I didn't realize that chrono::DateTime<chorono_tz::Tz> wasn't serde-serializable, even with the serde feature enabled for both crates. That's where the biggest problem probably lies.

In the example, using chorono_tz::Tz, and only converting to-be-serialized values to FixedOffset would probably put better focus on where the limitations/issues actually lie.

[–] [email protected] 2 points 3 months ago

OK, I've beefed that example up a little bit: https://github.com/BurntSushi/jiff/commit/08dfdde204c739e38147faf70b648e2d417d1c2e

I think the comparison is a bit more muddied now and probably worse overall to be honest. Maybe removing DateTime<Local> is the right thing to do. I'll think on it.

It's a subtle comparison to make... Probably most people don't even realize that they're doing the wrong thing.