Rewrite so that code compiles with chrono_tz 0.8.5 and 0.9.0 (#201)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-04-11 04:37:38 +05:30
committed by GitHub
parent 6a167143cb
commit 8c69dd491b

View File

@@ -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()
}
};