use crate::{
Date, Duration, Month, Seconds, TerrestrialTime, TimePoint, UniformDateTimeScale,
time_scale::{AbsoluteTimeScale, TimeScale},
units::Second,
};
pub type BeiDouTime<Representation = i64, Period = Second> = TimePoint<Bdt, Representation, Period>;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Bdt;
impl TimeScale for Bdt {
const NAME: &'static str = "BeiDou Time";
const ABBREVIATION: &'static str = "BDT";
}
impl AbsoluteTimeScale for Bdt {
const EPOCH: Date<i32> = match Date::from_historic_date(2006, Month::January, 1) {
Ok(epoch) => epoch,
Err(_) => unreachable!(),
};
}
impl UniformDateTimeScale for Bdt {}
impl TerrestrialTime for Bdt {
type Representation = i8;
type Period = Second;
const TAI_OFFSET: Duration<Self::Representation, Self::Period> = Seconds::new(-33);
}
#[test]
fn known_timestamps() {
use crate::{IntoTimeScale, UtcTime};
let utc = UtcTime::from_historic_datetime(2006, Month::January, 1, 0, 0, 0).unwrap();
let bdt = BeiDouTime::from_historic_datetime(2006, Month::January, 1, 0, 0, 0).unwrap();
assert_eq!(utc, bdt.into_time_scale());
}