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")]
18#[allow(clippy::std_instead_of_core)]
19impl std::error::Error for IndeterminateOffset {}
20
21impl From<IndeterminateOffset> for crate::Error {
22    fn from(err: IndeterminateOffset) -> Self {
23        Self::IndeterminateOffset(err)
24    }
25}
26
27impl TryFrom<crate::Error> for IndeterminateOffset {
28    type Error = error::DifferentVariant;
29
30    fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
31        match err {
32            crate::Error::IndeterminateOffset(err) => Ok(err),
33            _ => Err(error::DifferentVariant),
34        }
35    }
36}