Working with dates and times
The module std::time lets you work with the system time, and provides you with only the basic concepts of Instant and Duration (which we used in working with threads, see Chapter 9, Concurrency - Coding for Multicore Execution).
For any functionality beyond that, you need a crate. There are more than a dozen of them, with some specialized towards friendly output or games. The chrono crate is the most popular, however, and provides you with the most functionality, for example dates and times, timezones, and a wealth of formatting possibilities. Consult the docs for a complete overview https://docs.rs/chrono/0.4.0/chrono/.
Let's use a simple example to write the current local time to a file, applying what we learned ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access