From d6f4673b493ce2d9345fe24980ef88b85d2928d9 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 28 Aug 2021 20:10:58 +0200 Subject: [PATCH] ics: treat times ending with 'Z' as UTC --- libticker/src/ics/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libticker/src/ics/mod.rs b/libticker/src/ics/mod.rs index 32cdca0..6e361fc 100644 --- a/libticker/src/ics/mod.rs +++ b/libticker/src/ics/mod.rs @@ -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 { NaiveDateTime::parse_from_str(s, "%Y%m%dT%H%M%SZ") + .map(|time| DateTime::::from_utc(time, Utc).naive_local()) .or_else(|_| NaiveDateTime::parse_from_str(s, "%Y%m%dT%H%M%S")) .map(Timestamp::DateTime) .or_else(|_|