Date and Time
Manage the complexity of dealing with the fourth dimension.
There are two key libraries:
chrono
⮳: a comprehensive, full-featured, yet complex date and time library.time
⮳: a smaller, simpler library with limited functionality.
There is no clear answer as to which is best between time
⮳ and chrono
⮳. Evaluate for yourself between these two, but both are trusted and well-maintained.
Topic | Rust Crates |
---|---|
Date and Time Types | chrono ⮳, time ⮳ (newer crate, often preferred) |
Time Zones | chrono-tz ⮳, time ⮳ (built-in support) |
Formatting and Parsing | chrono ⮳, time ⮳ |
Durations and Time Intervals | chrono ⮳, time ⮳ |
Clock and Time Measurement | std::time ⮳ (for basic timekeeping), measure_time ⮳ (for convenient benchmarking) |
Duration and Calculation
Recipe | Crates | Categories |
---|---|---|
Measure the Elapsed Time Between Two Code Sections | ||
Perform Checked Date and Time Calculations | ||
Convert a Local Time to Another Timezone |
Parsing and Displaying
Recipe | Crates | Categories |
---|---|---|
Examine the Date and Time | ||
Convert Date to UNIX Timestamp and Vice Versa | ||
Display Formatted Date and Time | ||
Parse a String into a DateTime Struct | ||
humantime |
Using the time
Crate
Recipe | Crates | Categories |
---|---|---|
Use the time Crate |