Skip to main content

tempoch_core/format/
markers.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 Vallés Puig, Ramon
3
4//! Built-in external time-format markers.
5
6use crate::foundation::sealed::Sealed;
7use qtty::unit::{Day as DayUnit, Second as SecondUnit};
8
9use super::time_format::TimeFormat;
10
11/// Julian Day (days since noon 1 January 4713 BC on the proleptic Julian
12/// calendar, TT axis by convention).
13#[derive(Debug, Copy, Clone)]
14pub struct JD;
15impl Sealed for JD {}
16impl TimeFormat for JD {
17    type Unit = DayUnit;
18    const NAME: &'static str = "JD";
19}
20
21/// Modified Julian Day (`JD − 2 400 000.5`).
22#[derive(Debug, Copy, Clone)]
23pub struct MJD;
24impl Sealed for MJD {}
25impl TimeFormat for MJD {
26    type Unit = DayUnit;
27    const NAME: &'static str = "MJD";
28}
29
30/// SI seconds since J2000.0 TT (2000-01-01T12:00:00 TT).
31#[derive(Debug, Copy, Clone)]
32pub struct J2000s;
33impl Sealed for J2000s {}
34impl TimeFormat for J2000s {
35    type Unit = SecondUnit;
36    const NAME: &'static str = "J2000s";
37}
38
39/// POSIX (Unix) seconds since 1970-01-01T00:00:00 UTC.
40#[derive(Debug, Copy, Clone)]
41pub struct Unix;
42impl Sealed for Unix {}
43impl TimeFormat for Unix {
44    type Unit = SecondUnit;
45    const NAME: &'static str = "Unix";
46}
47
48/// GPS seconds since 1980-01-06T00:00:00 TAI.
49#[derive(Debug, Copy, Clone)]
50pub struct GPS;
51impl Sealed for GPS {}
52impl TimeFormat for GPS {
53    type Unit = SecondUnit;
54    const NAME: &'static str = "GPS";
55}