From 8c69dd491be1d6022b5e2865133aede2066da3c2 Mon Sep 17 00:00:00 2001 From: Anand Krishnamoorthi <35780660+anakrish@users.noreply.github.com> Date: Thu, 11 Apr 2024 04:37:38 +0530 Subject: [PATCH] Rewrite so that code compiles with chrono_tz 0.8.5 and 0.9.0 (#201) Signed-off-by: Anand Krishnamoorthi --- src/builtins/time.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/builtins/time.rs b/src/builtins/time.rs index 2101d31..1087ed8 100644 --- a/src/builtins/time.rs +++ b/src/builtins/time.rs @@ -9,7 +9,7 @@ use crate::value::Value; use std::collections::HashMap; -use anyhow::{anyhow, bail, Result}; +use anyhow::{bail, Result}; use chrono::{ DateTime, Datelike, Days, FixedOffset, Local, Months, SecondsFormat, TimeZone, Timelike, Utc, @@ -248,7 +248,10 @@ fn parse_epoch( "UTC" | "" => Utc.timestamp_nanos(ns).fixed_offset(), "Local" => Local.timestamp_nanos(ns).fixed_offset(), _ => { - let tz: Tz = tz.parse().map_err(|err: String| anyhow!(err))?; + let tz: Tz = match tz.parse() { + Ok(tz) => tz, + Err(e) => bail!(e), + }; tz.timestamp_nanos(ns).fixed_offset() } };