use chrono::offset::LocalResult;
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use chrono_tz::Tz;
pub fn local_instant(local: NaiveDateTime, zone: Tz) -> Result<DateTime<Utc>, String> {
match zone.from_local_datetime(&local) {
LocalResult::Single(instant) | LocalResult::Ambiguous(instant, _) => Ok(instant.to_utc()),
LocalResult::None => Err(format!(
"a time that does not exist in {zone}, whose clocks go forward past it"
)),
}
}