rscel 1.0.8

Cel interpreter in rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::str::FromStr;

use chrono::{DateTime, Utc};
use chrono_tz::Tz;

use crate::{CelError, CelResult};

pub fn get_adjusted_datetime(this: DateTime<Utc>, timezone: String) -> CelResult<DateTime<Tz>> {
    if let Ok(tz) = Tz::from_str(&timezone) {
        Ok(this.with_timezone(&tz))
    } else {
        Err(CelError::argument("Failed to parse timezone"))
    }
}