ics: fix Utc to Local timezone conversion

This commit is contained in:
Astro 2021-09-02 16:51:26 +02:00
parent 26be1853ce
commit 853656208d
1 changed files with 5 additions and 2 deletions

View File

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