cftime_rs/
timezone.rs

1#[derive(Debug, PartialEq, Clone, Copy)]
2pub struct Tz {
3    hour: i8,
4    minute: u8,
5}
6
7impl Tz {
8    pub fn new(hour: i8, minute: u8) -> Result<Self, crate::errors::Error> {
9        if !(-23..=23).contains(&hour) {
10            return Err(crate::errors::Error::InvalidTz(format!(
11                "Hour is out of bounds {}:{}",
12                hour, minute
13            )));
14        }
15        if minute > 59 {
16            return Err(crate::errors::Error::InvalidTz(format!(
17                "Minute is out of bounds {}:{}",
18                hour, minute
19            )));
20        }
21        Ok(Self { hour, minute })
22    }
23}