I can't figure this out from the docs or find an example. Here's my first try:
use chrono::{Utc, TimeZone};
fn main()
{
match Utc.datetime_from_str("2020-03-18T23:08:36.8098960+05:30", "%+") {
Ok(time) => {
println!("bingo: {}", time);
}
Err(e) => {
println!("woops: {}", e);
}
};
}
Then I tried this:
chrono::{Utc, DateTime, Local, TimeZone};
fn main()
{
match Local.datetime_from_str("2020-03-18T23:08:36.8098960+05:30", "%+") {
Ok(time) => {
let then_utc: DateTime<Utc> = time.with_timezone(&Utc);
println!("bingo: {}", then_utc);
}
Err(e) => {
println!("woops: {}", e);
}
};
}
Update: From responses to 28 September this looks like a bug so I created issue #489.