ics: treat times ending with 'Z' as UTC

This commit is contained in:
Astro 2021-08-28 20:10:58 +02:00
parent 483bc35e67
commit d6f4673b49
1 changed files with 2 additions and 1 deletions

View File

@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::fmt::Write;
use std::str::FromStr;
use chrono::{NaiveDate, NaiveDateTime};
use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc};
mod tokenizer;
mod parser;
@ -94,6 +94,7 @@ impl FromStr for Timestamp {
fn from_str(s: &'_ str) -> Result<Self, Self::Err> {
NaiveDateTime::parse_from_str(s, "%Y%m%dT%H%M%SZ")
.map(|time| DateTime::<Utc>::from_utc(time, Utc).naive_local())
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y%m%dT%H%M%S"))
.map(Timestamp::DateTime)
.or_else(|_|