time/error/
indeterminate_offset.rs

1//! Indeterminate offset
2
3use core::fmt;
4
5use crate::error;
6
7/// The system's UTC offset could not be determined at the given datetime.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct IndeterminateOffset;
10
11impl fmt::Display for IndeterminateOffset {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        f.write_str("The system's UTC offset could not be determined")
14    }
15}
16
17#[cfg(feature = "std")]
18impl std::error::Error for IndeterminateOffset {}
19
20impl From<IndeterminateOffset> for crate::Error {
21    fn from(err: IndeterminateOffset) -> Self {
22        Self::IndeterminateOffset(err)
23    }
24}
25
26impl TryFrom<crate::Error> for IndeterminateOffset {
27    type Error = error::DifferentVariant;
28
29    fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
30        match err {
31            crate::Error::IndeterminateOffset(err) => Ok(err),
32            _ => Err(error::DifferentVariant),
33        }
34    }
35}