Integer division is confusing

The rounding behaviour of integer division is counter-intuitive. Let’s look at two examples that’ll make you think.

Convert a UNIX timestamp to Rust

Source code listing with Rust source code.

The general strategy is to convert the integer to a type that’s unaware of time zones, such as chrono::NaiveDateTime, then convert that time to one that’s timezone-aware, such as chrono::Utc.

Example Article

The excerpt serves as a way to store the subtitle of this post.