use std::fmt::Debug;
#[cfg(feature = "bitcode")]
use bitcode::{Decode, Encode};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::duration::Duration;
pub trait Standard: Debug + Sized + Copy {
fn abbrev() -> &'static str;
fn tt_offset() -> Duration;
fn tt_scale() -> Option<f64>;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "bitcode", derive(Decode, Encode))]
pub struct Tt;
impl Standard for Tt {
fn abbrev() -> &'static str {
"TT"
}
fn tt_offset() -> Duration {
Duration::new(0, 0)
}
fn tt_scale() -> Option<f64> {
None
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "bitcode", derive(Decode, Encode))]
pub struct Tai;
impl Standard for Tai {
fn abbrev() -> &'static str {
"TAI"
}
fn tt_offset() -> Duration {
Duration::new(32, 184_000_000_000_000_000)
}
fn tt_scale() -> Option<f64> {
None
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "bitcode", derive(Decode, Encode))]
pub struct Utc;
impl Standard for Utc {
fn abbrev() -> &'static str {
"UTC"
}
fn tt_offset() -> Duration {
Duration::new(41, 184_000_000_000_000_000)
}
fn tt_scale() -> Option<f64> {
None
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "bitcode", derive(Decode, Encode))]
pub struct Tcg;
impl Standard for Tcg {
fn abbrev() -> &'static str {
"TCG"
}
fn tt_offset() -> Duration {
Duration::new(0, 0)
}
fn tt_scale() -> Option<f64> {
Some(6.969_290_134e-10)
}
}