-
Notifications
You must be signed in to change notification settings - Fork 537
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
Differences between this crate and time
#1423
Comments
As a mini-history, glossing over all details: before the release of rust 1.0 time-rs had the simple platform interfaces, and chrono was the date-time library. At some point time-rs was deprecated and chrono absorbed its functionality. Then chrono became unmaintained for a while, and time-rs became a new crate with a simplified part of chrono's API. Now both are actively developed again. Chrono 0.4.33 vs time 0.3.34
I am of course biased. In my opinion chrono has the better implementations (this is all not meant as bragging, it is not designed by me). Unique features: Operations on dates can be very fast thanks to a smart internal representation. Chrono can correctly recognize tricky invalid cases when parsing (see the On the other hand chrono is quite old and predates current API standards. Time is more ergonomic to use at the moment, at least until chrono 0.5. Chrono uses the not-that-readable Consider also asking for the time crate (time-rs/time#308) for less bias 😄. |
chrono has a much more conservative MSRV. time is increasingly splitting out more dependencies. |
I would say you basically can't go wrong with either. time is a bit more popular right now. |
Corrections/clarifications on my end (as maintainer of
This is because DST transitions do not exist in fixed-offset implementations.
In progress!
This is fully supported.
The "user guarantee" is not the case. Soundness is guaranteed. The only exception is if someone falsely asserts (in an unsafe context!) that they are upholding the soundness requirements. |
|
Oh, that is a much smaller difference than I thought, nice! Still wary of the policy, though. |
I keep track of a number of features. Ultimately I don't see the MSRV being bumped in the near future, as nothing being tracked is close to stabilization and has sufficient impact. |
Nice, good to have your input @jhpratt!
Yes. Not meant as critique of time. Dealing with this just might be a feature someone would want and could help choosing a library.
At the time I though I missed something with the timezone names, but haven't found the relevant parts back agin in your crate.
Really? Nice.
I guess we can call it: 'requires single thread or platform guarantees for soundness' I'll update the table in my comment. It came from some notes while I was looking into the differences for myself, and wanted to give something mostly right instead of nothing 😄. Good to have some form of comparison anyway. |
Absolutely! My remark there was more for context, as it's implied by the other row.
It was an open issue for quite a while, but I was able to obtain the 2019 version of the spec (the most recent) when a company purchased it in my name.
That's a fair way to word it.
Depending on how long ago it was done, some of the info may have been accurate at the time. It's certainly good to have something, as it's hard to be impartial, particularly given that I haven't used |
Well, I think 17% more qualifies as a "bit more" -- but yeah, it's definitely same order of magnitude. |
time
?time
@pitdicker maybe you can add another important difference in the table: with |
Why are there no conversion options between time and chrono? As a new rust developer, I'm finding trying to figure out chrono to be pretty unnerving and frustrating. For example, using the solar-calendar-events crate: let equinox: time::OffsetDateTime = MarchEquinox::new(year).unwrap().date_time().unwrap(); Now, I want to convert that from an let tehran = Tehran
.with_ymd_and_hms(year, 3, equinox.day() as u32, 0, 0, 0)
.unwrap();
tehran.with_time(equinox.time());
So they seem totally incompatible (without having to convert to/from UNIX timestamp, I guess?). Time zones and dealing with time are a real pain in most languages, but they don't have to be in Rust, as the compiler should help you. The methods and auto-suggestions on chrono (and chrono-tz) just don't seem intuitive to me, and the documentation lacks many examples on how to just parse time from a database with a dynamic time zone like most people do (how many people really hard-code their timezones in apps?). But my main point here is that between these two popular crates, there is no way to convert (!!!), while most other languages (Dart, Python, etc.) have centered around pretty standard time structures and good documentation on how to deal with and convert them. Even JavaScript has luxon, which provides a means to convert between it and other types. |
Due to the notion of coherence in the language, providing conversion routines would mean one of these crates taking a dependency on the other. That would kind of defeat the purpose of picking a single one... So yes, these crates have evolved independently and they are completely "incompatible" at the type system level. If you have constructive specific feedback on our API or the documentation, we're happy to discuss those in a separate issues. |
I'm new to Rust and I'm wondering: what substantial differences are there between this crate and time?
The text was updated successfully, but these errors were encountered: