No_std way to convert from human-readable UTC time to UNIX timestamp and back

I was always under the impression that converting from human-readable UTC date like 2022-10-19 to a UNIX timestamp and back fundamentally requires talking to the operating system. However, today I've learned that that's not actually the case, and there's a closed formula to do that correctly:

(that's because UNIX time only counts real seconds, so each day always has an exact number of seconds).

Hence, the question: which zero-dependency crate allows me to (const) convert yyy:mm:dd:hh:mm:ss to SystemTime and back? Can we just add this to stdlib as methods of SystemTime?

The question is prompted by a chrono's update bringing cxx of all the things into my lockfile :rofl:

3 Likes

Apparentlyn humantime — Rust date/time library // Lib.rs is what I am looking for.