use crate::{
Date, Duration, Month, Seconds, TerrestrialTime, TimePoint, UniformDateTimeScale,
time_scale::{AbsoluteTimeScale, TimeScale},
units::Second,
};
pub type QzssTime<Representation = i64, Period = Second> = TimePoint<Qzsst, Representation, Period>;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Qzsst;
impl TimeScale for Qzsst {
const NAME: &'static str = "Quasi-Zenith Satellite System Time";
const ABBREVIATION: &'static str = "QZSST";
}
impl AbsoluteTimeScale for Qzsst {
const EPOCH: Date<i32> = match Date::from_historic_date(1999, Month::August, 22) {
Ok(epoch) => epoch,
Err(_) => unreachable!(),
};
}
impl UniformDateTimeScale for Qzsst {}
impl TerrestrialTime for Qzsst {
type Representation = i8;
type Period = Second;
const TAI_OFFSET: Duration<Self::Representation, Self::Period> = Seconds::new(-19);
}
#[test]
fn known_timestamps() {
use crate::{IntoTimeScale, TaiTime};
let tai =
TaiTime::<i64, Second>::from_historic_datetime(2004, Month::May, 14, 16, 43, 32).unwrap();
let qzsst = QzssTime::from_historic_datetime(2004, Month::May, 14, 16, 43, 13).unwrap();
assert_eq!(tai, qzsst.into_time_scale());
}