Issue
How would I convert a human readable time (in any format, such as Tue, 1 Jul 2003 10:52:37 +0200
) into a SystemTime
, in a cross-platform way? I know about chrono::DateTime::from_rfc2822()
, but I've been searching for quite a while and I can't find a way to convert a DateTime
into a SystemTime
. This conversion also needs to be cross-platform, so I can't use the platform-specific epochs (such as UNIX_EPOCH
).
Does anyone have any advice or ideas on how to do this?
Solution
There is a conversion available for DateTime<Tz>
to SystemTime
, so you just need to call .into()
:
let system_time: SystemTime = DateTime::parse_from_rfc2822("Tue, 1 Jul 2003 10:52:37 +0200").unwrap().into();
Answered By - kmdreko Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.