Rust's chrono
has been very frustrating to work with as it makes converting from timezones very difficult.
For example: my user inputs a string. I parse this into a naive date time using NaiveDateTime::parse_from_str
. Now I would like to convert this into a DateTime<Local>
.
Unfortunately I can't seem to find out how to do so. Using Local::From
doesn't work. Using DateTime<Local>::from()
doesn't work either. Neither structs have methods to convert from a NaiveDateTime
, and NaiveDateTime
doesn't have methods to convert into Local
.
Yet, we can do things like this: someLocalDateTime.date().and_time(some_naive_time)
. So why can't we just do Local::new(some_naive_date_time)
?
Additionally, why can't we skip fields in the parsing? I don't need seconds and I don't need year. In order to assume the current year and 0 seconds, I have to manually write parsing code and construct the datetime from ymd hms.