|
SatCat5
|
Real-time clock conversion functions.
The preferred representation for SatCat5 real-time functions is the number of milliseconds since the GPS epoch (i.e., midnight between 1980 Jan 5 and Jan 6). This file defines various conversions to and from this format.
(This is separate from the more precise satcat5::ptp::Time class used for PTP.)
GPS time has the advantage that it has no time-zones, no leap-seconds, etc. By definition, GPS time is always behind TAI by exactly 19 seconds. Because UTC inserts leap seconds every few years, the offset from GPS to UTC varies. From 2017-2025, GPS has lead UTC by 18 seconds.
Conversion functions to human-readable calendar formats are effectively in a GPS "time-zone" that is more-or-less equivalent to TAI/UTC as noted above.
For more information, including the current GPS/TAI/UTC time: http://www.leapsecond.com/java/gpsclock.htm For an online conversion tool: https://www.labsat.co.uk/index.php/en/gps-time-calculator
Definition in file datetime.h.
#include <satcat5/io_core.h>#include <satcat5/polling.h>#include <satcat5/ptp_time.h>#include <satcat5/timeref.h>Go to the source code of this file.
Classes | |
| struct | satcat5::datetime::GpsTime |
| GPS week-number and time-of-week. More... | |
| struct | satcat5::datetime::RtcTime |
| Hardware RTC (e.g., Renesas ISL12082). More... | |
| class | satcat5::datetime::Clock |
| Real-time clock for tracking date/time. More... | |
Functions | |
| satcat5::datetime::GpsTime | satcat5::datetime::to_gps (s64 time) |
| Convert an internal timestamp into the designated format. More... | |
| satcat5::ptp::Time | satcat5::datetime::to_ptp (s64 time) |
| Convert an internal timestamp into the designated format. More... | |
| satcat5::datetime::RtcTime | satcat5::datetime::to_rtc (s64 time) |
| Convert an internal timestamp into the designated format. More... | |
| s64 | satcat5::datetime::from_gps (const satcat5::datetime::GpsTime &time) |
| Convert the designated format into an internal timestamp. More... | |
| s64 | satcat5::datetime::from_ptp (const satcat5::ptp::Time &time) |
| Convert the designated format into an internal timestamp. More... | |
| s64 | satcat5::datetime::from_rtc (const satcat5::datetime::RtcTime &time) |
| Convert the designated format into an internal timestamp. More... | |
Variables | |
| static constexpr s64 | satcat5::datetime::TIME_ERROR = 0 |
| A date/time of zero indicates an error. | |
| static const datetime::RtcTime | satcat5::datetime::RTC_ERROR = {0, 0, 0, 0, 0, 0, 0, 0, 0} |
| Special datetime::RtcTime value indicating an error. | |
| static const u8 | satcat5::datetime::RTC_MIL_BIT = 0x80 |
| Bit-flag in HR field indicating 24-HOUR clock format. More... | |
| satcat5::datetime::Clock | satcat5::datetime::clock |
| Global instance of the datetime::Clock class. More... | |
| static constexpr u32 | satcat5::datetime::ONE_SECOND = 1000 |
| Common time-related constants, measured in milliseconds. More... | |
| static constexpr u32 | satcat5::datetime::ONE_MINUTE = 60 * ONE_SECOND |
| Common time-related constants, measured in milliseconds. More... | |
| static constexpr u32 | satcat5::datetime::ONE_HOUR = 60 * ONE_MINUTE |
| Common time-related constants, measured in milliseconds. More... | |
| static constexpr u32 | satcat5::datetime::ONE_DAY = 24 * ONE_HOUR |
| Common time-related constants, measured in milliseconds. More... | |
| static constexpr u32 | satcat5::datetime::ONE_WEEK = 7 * ONE_DAY |
| Common time-related constants, measured in milliseconds. More... | |
| s64 satcat5::datetime::from_gps | ( | const satcat5::datetime::GpsTime & | time | ) |
Convert the designated format into an internal timestamp.
Explanation of the SatCat5 datetime format.
Definition at line 191 of file datetime.cc.
| s64 satcat5::datetime::from_ptp | ( | const satcat5::ptp::Time & | time | ) |
Convert the designated format into an internal timestamp.
Explanation of the SatCat5 datetime format.
Definition at line 22 of file datetime.cc.
| s64 satcat5::datetime::from_rtc | ( | const satcat5::datetime::RtcTime & | time | ) |
Convert the designated format into an internal timestamp.
Explanation of the SatCat5 datetime format.
Definition at line 239 of file datetime.cc.
| GpsTime satcat5::datetime::to_gps | ( | s64 | time | ) |
Convert an internal timestamp into the designated format.
Explanation of the SatCat5 datetime format.
Definition at line 184 of file datetime.cc.
| ptp::Time satcat5::datetime::to_ptp | ( | s64 | time | ) |
Convert an internal timestamp into the designated format.
Explanation of the SatCat5 datetime format.
Definition at line 26 of file datetime.cc.
| RtcTime satcat5::datetime::to_rtc | ( | s64 | time | ) |
Convert an internal timestamp into the designated format.
Explanation of the SatCat5 datetime format.
Definition at line 195 of file datetime.cc.
|
extern |
Global instance of the datetime::Clock class.
This instance is provided for general-use and convenience, but specialized use-cases may create and manage their own clocks.
Definition at line 16 of file datetime.cc.
|
staticconstexpr |
Common time-related constants, measured in milliseconds.
e.g., One week = 604,800,000 milliseconds.
Definition at line 46 of file datetime.h.
|
staticconstexpr |
Common time-related constants, measured in milliseconds.
e.g., One week = 604,800,000 milliseconds.
Definition at line 45 of file datetime.h.
|
staticconstexpr |
Common time-related constants, measured in milliseconds.
e.g., One week = 604,800,000 milliseconds.
Definition at line 44 of file datetime.h.
|
staticconstexpr |
Common time-related constants, measured in milliseconds.
e.g., One week = 604,800,000 milliseconds.
Definition at line 43 of file datetime.h.
|
staticconstexpr |
Common time-related constants, measured in milliseconds.
e.g., One week = 604,800,000 milliseconds.
Definition at line 47 of file datetime.h.
|
static |
Bit-flag in HR field indicating 24-HOUR clock format.
When calling RtcTime::write_to, this flag is always set.
Definition at line 158 of file datetime.h.