You are viewing a single thread.
View all comments View context
1 point

Why is the full presentation non-ephemerally stored instead of (timestamp, timezoe)?

Is the use-case strictly limited to checking the validity of a future date that was generated with assumptions based on current tzdata info? That’s valid, but quite niche I would argue.

And one can adjust the wrapper to have (timestamp, timezone, assumed_offset_at_ts). But yes, it can be argued that it’s not idiomatic/automatic/antecedently obvious anymore.

permalink
report
parent
reply
1 point

And the fact that you need to create a wrapper means that some programmers won’t bother to do it, or won’t know they need to do it. The default case handling timezones correctly will reduce potential errors.

permalink
report
parent
reply
1 point

Time zone transition changes happen all the time. Once you start storing datetimes in the future, you’re in a bit of a precarious position here. Moreover, this is a standardized interchange format that other libraries will know how to read/write. (It’s relatively newly standardized, but has been used in practice among other datetime libraries.)

I think you also glossed over some of my other points. How do you write your serialization code using Chrono? Does it work with both chrono-tz and tzfile?

The point is almost never about “it is literally impossible to accomplish task foo,” but rather, it matters how it’s approach and how easy it is to do. And if you have to rely on your users having very specific domain knowledge about this, it’s likely there will be errors. As my design docs state, I didn’t only make Jiff to offer more functionality. I also made it because I felt like the APIs could be better. That’s a very subjective valuation, and I find arguments of the type, “well I can just use the old library in this way as long as I hold it right and it actually works just fine” to be missing the forest for the trees.

permalink
report
parent
reply
1 point
*

I think you also glossed over some of my other points. How do you write your serialization code using Chrono? Does it work with both chrono-tz and tzfile?

Something like this?

It can support tzfile too around the wire if it starts to expose tz names in a future version.

permalink
report
parent
reply
1 point
*

Again, to be clear, I’m not saying it’s impossible to do. But in order to do it, you have to build your own abstractions. And even then, you still can’t do it because tzfile doesn’t give you enough to do it. And tzfile has a platform specific API with no caching, so every time you parse a datetime with a tz ID in it, it’s completely reloading the TZif data from disk.

Some of these things are implementation quality issues that can be fixed. Others are library design problems where you can achieve your objective by building your own abstractions. Like do you really not see this as something that shouldn’t be mentioned in a comparison between these crates? You must recognize the difference between what you’re doing and just plopping a Zoned in your struct, deriving Serialize and Deserialize, and then just letting the library do the right thing for you. And that mentioning this is appropriate in the context of the “facts of comparison” because it translates into a real user experience difference for callers.

permalink
report
parent
reply

Rust

!rust@programming.dev

Create post

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

Wormhole

!performance@programming.dev

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

Community stats

  • 572

    Monthly active users

  • 812

    Posts

  • 3.7K

    Comments