I'm having some issues when handling date/time stamps within Rust. The first issue is the type of date/time stamp which (I believe) is ISO 8601 zero meridean w/ local time zone offset. Here's the format: "2023-09-09T10:24:10.239000-07:00" which comes from Jira's REST API ie its creation date. Outside of struggles with chrono handling that date, I've actually tried speedate which has been quite faster... however, I'm struggling to figure out a way to calculate a datetime which is 30 days in the past, to determine whether or not something is over 30 days old.
I've tried using speedate:
let test_parser = DateTime::parse_str(serde_json::from_str(&creation_date).unwrap());
Which was quite a bit faster in handling. Although, I couldn't figure out a way to subtract or handle calculating a date that was 30 days from today, and then comparing test_parser to 30daysago to determine whether or not something is older than 30 days.
I did find a chrono function which could do something similar which was using chrono::Duration::days(-30) however, I couldn't compare duration to datetime, and I had challenges getting Chrono to parse that datetime, in comparison to speedate which parsed it well.
You can use a custom format in
chronoto parse your datetime:%Y-%m-%dT%H:%M:%S%.f%z.For example, to compare to 30 days ago: