jiff/error/tz/
timezone.rs

1use crate::error;
2
3#[derive(Clone, Debug)]
4pub(crate) enum Error {
5    ConvertNonFixed {
6        kind: &'static str,
7    },
8    #[cfg(not(feature = "tz-system"))]
9    FailedSystem,
10}
11
12impl From<Error> for error::Error {
13    #[cold]
14    #[inline(never)]
15    fn from(err: Error) -> error::Error {
16        error::ErrorKind::TzTimeZone(err).into()
17    }
18}
19
20impl error::IntoError for Error {
21    fn into_error(self) -> error::Error {
22        self.into()
23    }
24}
25
26impl core::fmt::Display for Error {
27    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
28        use self::Error::*;
29
30        match *self {
31            ConvertNonFixed { kind } => write!(
32                f,
33                "cannot convert non-fixed {kind} time zone to offset \
34                 without a timestamp or civil datetime",
35            ),
36            #[cfg(not(feature = "tz-system"))]
37            FailedSystem => f.write_str("failed to get system time zone"),
38        }
39    }
40}