Home > database >  convert u32 to SystemTime
convert u32 to SystemTime

Time:07-26

In rust, how can I convert a u32 Unix Epoch based value into a std::time::SystemTime ?

In my case, the u32 value is from a gzip header modified time.



Converse question: How can I convert SystemTime::now() to an integer type?.

CodePudding user response:

Add a Duration to SystemTime::UNIX_EPOCH:

let time = SystemTime::UNIX_EPOCH   Duration::from_secs(value);
  • Related