3 ms·
Rust - because it doesn't have date and time in the standard library! I believe the standard library developers knew date/time was cursed, so punted on it. The
by twic 5y ago
Rust - because it doesn't have date and time in the standard library!
I believe the standard library developers knew date/time was cursed, so punted on it. There is a minimal set of types and functions to allow the bare minimum of system calls etc:
https://doc.rust-lang.org/std/time/index.html https://doc.rust-lang.org/std/time/index.html
But you have to bring in one of a few crates to do anything else.
- Macha 5y agochrono is the defacto standard. As with all good modern datetime libs (see also Noda Time, the new java.time), it takes liberal inspiration from Joda Time, which IMO has pretty much set the template for a robust datetime library.
- nextaccountic 5y agoYep! Most examples in the Rust cookbook[0] use chrono[1]. But note that before Chrono there were other time libraries; one of them was called time[2] - and IIRC it was created from code removed from Rust's stdlib std::time[3]. It eventually proved to be the best decision: designing a good API is a hard effort, and any design was prone to have mistakes and warts. Chrono provides interoperability with both std::time and the time crate. It acknowledges other datetime crates that it was inspired, like datetime-rs[3] which itself was inspired by Joda time. [0] https://rust-lang-nursery.github.io/rust-cookbook/datetime.html https://rust-lang-nursery.github.io/rust-cookbook/datetime.h... [1] https://crates.io/crates/chrono https://crates.io/crates/chrono [2] https://crates.io/crates/time https://crates.io/crates/time [3] https://github.com/depp/datetime-rs https://github.com/depp/datetime-rs
- andyfleming 5y agoThere's an actual joda implementation as well. See https://www.npmjs.com/package/@js-joda/core https://www.npmjs.com/package/@js-joda/core
- Gigachad 5y agoAt least with this way, you don't have to hang on to bad ideas and specs for eternity. A bad crate can easily be swapped out for a better one and future developers won't have to remember which is the good date functions.