diff options
-rw-r--r-- | src/icaltool.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/icaltool.rs b/src/icaltool.rs index 9910463..2a81a68 100644 --- a/src/icaltool.rs +++ b/src/icaltool.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use chrono::{DateTime, FixedOffset, Utc}; +use chrono::{NaiveDateTime, Utc}; use ical::{ IcalParser, parser::ical::component::{ @@ -66,7 +66,8 @@ impl Icaltool { } } -fn parse_datetime(datetime: Option<String>) -> Option<DateTime<FixedOffset>> { +fn parse_datetime(datetime: Option<String>) -> Option<NaiveDateTime> { + dbg!(&datetime); if let Some(mut dt) = datetime { if dt.is_empty() { return None; @@ -75,7 +76,8 @@ fn parse_datetime(datetime: Option<String>) -> Option<DateTime<FixedOffset>> { if !dt.contains('T') { dt += "T000000"; } - DateTime::parse_from_str(&dt, "%Y%m%dT%H%M%S").ok() + dbg!(&dt); + dbg!(NaiveDateTime::parse_from_str(&dt, "%Y%m%dT%H%M%S").ok()) } else { None @@ -83,8 +85,8 @@ fn parse_datetime(datetime: Option<String>) -> Option<DateTime<FixedOffset>> { } fn print_event(event: &IcalEvent) { - let mut start: Option<DateTime<FixedOffset>> = None; - let mut end: Option<DateTime<FixedOffset>> = None; + let mut start: Option<NaiveDateTime> = None; + let mut end: Option<NaiveDateTime> = None; let mut summary = String::new(); let mut description = String::new(); @@ -99,8 +101,8 @@ fn print_event(event: &IcalEvent) { } println!("---> {} - {}: {}", - start.unwrap_or_else(|| Utc::now().fixed_offset()), - end.unwrap_or_else(|| Utc::now().fixed_offset()), + start.unwrap_or_else(|| Utc::now().naive_utc()), + end.unwrap_or_else(|| Utc::now().naive_utc()), summary); if description.len() > 0 { |