|
Time Shield Library
C++ library for working with time
|
Namespaces | |
| namespace | anonymous_namespace{fast_date.hpp} |
| namespace | format_parse |
Classes | |
| struct | DaySplit |
| struct | FastDate |
| class | NtpClientCore |
| Core NTP query logic that parses packets and computes offsets. More... | |
| struct | NtpPacket |
| NTP packet layout (48 bytes). More... | |
| struct | UdpRequest |
| UDP request parameters for NTP transactions. More... | |
| class | IUdpTransport |
| Abstract UDP transport interface for NTP queries. More... | |
| class | UdpTransportPosix |
| POSIX UDP transport for NTP queries. More... | |
| class | UdpTransportWin |
| Windows UDP transport for NTP queries. More... | |
| struct | NtpTimeServiceSingleton |
| struct | NtpTimeServiceTestAccess |
| class | FakeNtpRunner |
| Fake runner for tests without network access. More... | |
| struct | ZoneNameEntry |
| struct | TimerState |
| Internal state shared between Timer and TimerScheduler. More... | |
| struct | RunningTimerScope |
| struct | ScheduledTimer |
| Data stored in the priority queue of scheduled timers. More... | |
| struct | ScheduledComparator |
| Comparator that orders timers by earliest fire time. More... | |
| struct | DueTimer |
| Helper structure that represents a timer ready to run. More... | |
Typedefs | |
| using | PlatformUdpTransport = UdpTransportWin |
| using | TimerClock = std::chrono::steady_clock |
| using | TimerCallback = std::function<void()> |
Enumerations | |
| enum | NtpProtoError { NTP_EPROTO_BASE = -10000 , NTP_E_BAD_MODE = NTP_EPROTO_BASE - 1 , NTP_E_BAD_VERSION = NTP_EPROTO_BASE - 2 , NTP_E_BAD_LI = NTP_EPROTO_BASE - 3 , NTP_E_BAD_STRATUM = NTP_EPROTO_BASE - 4 , NTP_E_KOD = NTP_EPROTO_BASE - 5 , NTP_E_BAD_TS = NTP_EPROTO_BASE - 6 } |
| Protocol-level error codes for NTP parsing. More... | |
Functions | |
| TIME_SHIELD_CONSTEXPR DaySplit | split_unix_day (ts_t p_ts) noexcept |
| Split UNIX seconds into whole days and seconds-of-day. | |
| TIME_SHIELD_CONSTEXPR int64_t | fast_days_from_date_constexpr (int64_t p_year, int p_month, int p_day) noexcept |
| Convert date to days since Unix epoch using a fast constexpr algorithm. | |
| int64_t | fast_days_from_date (int64_t p_year, int p_month, int p_day) noexcept |
| Convert date to days since Unix epoch using a fast algorithm. | |
| TIME_SHIELD_CONSTEXPR FastDate | fast_date_from_days_constexpr (int64_t p_days) noexcept |
| Convert days since Unix epoch to date using a fast constexpr algorithm. | |
| FastDate | fast_date_from_days (int64_t p_days) noexcept |
| Convert days since Unix epoch to date using a fast algorithm. | |
| TIME_SHIELD_CONSTEXPR int64_t | fast_year_from_days_constexpr (int64_t p_days) noexcept |
| Convert days since Unix epoch to year using a fast constexpr algorithm. | |
| int64_t | fast_year_from_days (int64_t p_days) noexcept |
| Convert days since Unix epoch to year using a fast algorithm. | |
| template<class T> | |
| TIME_SHIELD_CONSTEXPR T | floor_div (T a, T b) noexcept |
| Floor division for positive divisor. | |
| template<class T> | |
| TIME_SHIELD_CONSTEXPR T | floor_mod (T a, T b) noexcept |
| Floor-mod for positive modulus (returns r in [0..b)). | |
| TIME_SHIELD_CONSTEXPR uint64_t | mul_hi_u64_constexpr (uint64_t p_a, uint64_t p_b) noexcept |
| Return the high 64 bits of a 64x64-bit multiplication (constexpr variant). | |
| uint64_t | mul_hi_u64 (uint64_t p_a, uint64_t p_b) noexcept |
| Return the high 64 bits of a 64x64-bit multiplication. | |
| uint64_t | mul_shift_u64 (uint64_t p_x, uint64_t p_c) noexcept |
| Alias for mul_hi_u64 used for shift-by-64 operations. | |
| TIME_SHIELD_CONSTEXPR uint64_t | mul_shift_u64_constexpr (uint64_t p_x, uint64_t p_c) noexcept |
| Alias for mul_hi_u64_constexpr used for shift-by-64 operations. | |
| jd_t | gregorian_dmy_to_jd_unchecked (double day, int64_t month, int64_t year) noexcept |
| jdn_t | gregorian_dmy_to_jdn_unchecked (int64_t day, int64_t month, int64_t year) noexcept |
| double | day_fraction_from_hms (int hour, int minute, int second, int millisecond) noexcept |
| static uint8_t | ntp_li (uint8_t li_vn_mode) noexcept |
| Extract leap indicator from LI/VN/Mode field. | |
| static uint8_t | ntp_vn (uint8_t li_vn_mode) noexcept |
| Extract version number from LI/VN/Mode field. | |
| static uint8_t | ntp_mode (uint8_t li_vn_mode) noexcept |
| Extract mode from LI/VN/Mode field. | |
| static uint64_t | ntp_frac_to_us (uint32_t frac_net) noexcept |
| Convert NTP fractional seconds to microseconds. | |
| static bool | ntp_ts_to_unix_us (uint32_t sec_net, uint32_t frac_net, uint64_t &out_us) noexcept |
| Convert NTP timestamp parts to Unix microseconds. | |
| static void | fill_client_packet (NtpPacket &pkt, uint64_t now_us) |
| Fill an NTP client request packet using local time. | |
| static bool | parse_server_packet (const NtpPacket &pkt, uint64_t arrival_us, int64_t &offset_us, int64_t &delay_us, int &stratum, int &out_error_code) noexcept |
| Parse server response and compute offset and delay. | |
| TIME_SHIELD_CONSTEXPR bool | oadate_can_cast_to_i64 (oadate_t value) noexcept |
| TIME_SHIELD_CONSTEXPR oadate_t | oadate_abs (oadate_t value) noexcept |
| TIME_SHIELD_CONSTEXPR oadate_t | oadate_trunc_toward_zero (oadate_t value) noexcept |
| TIME_SHIELD_CONSTEXPR oadate_t | oadate_floor_value (oadate_t value) noexcept |
| TIME_SHIELD_CONSTEXPR bool | oadate_has_fraction (oadate_t value) noexcept |
| TIME_SHIELD_CONSTEXPR oadate_t | linear_days_to_oadate (oadate_t linear_days) noexcept |
| TIME_SHIELD_CONSTEXPR oadate_t | oadate_to_linear_days (oadate_t oa) noexcept |
| std::string | trim_copy_ascii (const std::string &s) |
| Trim ASCII whitespace from both ends. | |
| std::string_view | trim_view_ascii (std::string_view v) |
| Trim ASCII whitespace from both ends (string_view). | |
| void | normalise_month_token_lower (const std::string &month, std::string &output) |
| Normalize month token to lower-case ASCII using current locale facet. | |
| void | normalise_month_token_lower (std::string_view month, std::string &output) |
| Normalize month token to lower-case ASCII using current locale facet (string_view). | |
| bool | try_parse_month_index (const std::string &month, int &value) |
| Try parse month name token into month index (1..12). | |
| bool | try_parse_month_index (std::string_view month, int &value) |
| Try parse month name token into month index (1..12), string_view overload. | |
| int | parse_month_index (const std::string &month) |
| Parse month name token into month index (1..12). | |
| int | parse_month_index (std::string_view month) |
| Parse month name token into month index (1..12), string_view overload. | |
| const std::array< ZoneNameEntry, 25 > & | time_zone_name_entries () noexcept |
| Return supported strict named-zone entries. | |
| bool | try_parse_time_zone_name_token (const char *data, std::size_t length, TimeZone &zone) noexcept |
| Parse strict named-zone token without trimming. | |
| TIME_SHIELD_CONSTEXPR bool | is_ascii_space (char c) noexcept |
| Check whether character is ASCII whitespace. | |
| TIME_SHIELD_CONSTEXPR bool | is_ascii_digit (char c) noexcept |
| Check whether character is ASCII digit. | |
| TIME_SHIELD_CONSTEXPR void | skip_spaces (const char *&p, const char *end) noexcept |
| Skip ASCII whitespace. | |
| TIME_SHIELD_CONSTEXPR bool | parse_2digits (const char *&p, const char *end, int &out) noexcept |
| Parse exactly 2 digits into int. | |
| TIME_SHIELD_CONSTEXPR bool | parse_4digits_year (const char *&p, const char *end, year_t &out) noexcept |
| Parse exactly 4 digits into year_t (via int). | |
| TIME_SHIELD_CONSTEXPR bool | parse_fraction_to_ms (const char *&p, const char *end, int &ms_out) noexcept |
| Parse fractional seconds (1..9 digits) and convert to milliseconds. | |
| ts_t | cet_to_gmt_impl (ts_t cet) |
| ts_t | gmt_to_cet_impl (ts_t gmt) |
| ts_t | european_local_to_gmt (ts_t local, int standard_offset_hours) |
| ts_t | gmt_to_european_local (ts_t gmt, int standard_offset_hours) |
| bool | is_us_eastern_dst_local (const DateTimeStruct &dt) |
| bool | fixed_zone_offset (TimeZone zone, tz_t &utc_offset) |
| ts_ms_t | zone_to_gmt_ms_by_seconds (ts_ms_t local_ms, TimeZone zone) |
| ts_ms_t | gmt_to_zone_ms_by_seconds (ts_ms_t gmt_ms, TimeZone zone) |
| TimerState *& | current_timer_state () |
Definition at line 34 of file ntp_client.hpp.
| using time_shield::detail::TimerCallback = std::function<void()> |
Definition at line 41 of file TimerScheduler.hpp.
| using time_shield::detail::TimerClock = std::chrono::steady_clock |
Definition at line 40 of file TimerScheduler.hpp.
Definition at line 25 of file time_zone_conversions.hpp.
|
inline |
Definition at line 57 of file TimerScheduler.hpp.
|
inlinenoexcept |
Definition at line 57 of file julian_conversions.hpp.
Definition at line 134 of file time_zone_conversions.hpp.
|
inlinenoexcept |
Convert days since Unix epoch to date using a fast algorithm.
Definition at line 156 of file fast_date.hpp.
|
inlinenoexcept |
Convert days since Unix epoch to date using a fast constexpr algorithm.
Definition at line 118 of file fast_date.hpp.
|
inlinenoexcept |
Convert date to days since Unix epoch using a fast algorithm.
Definition at line 90 of file fast_date.hpp.
|
inlinenoexcept |
Convert date to days since Unix epoch using a fast constexpr algorithm.
Definition at line 59 of file fast_date.hpp.
|
inlinenoexcept |
Convert days since Unix epoch to year using a fast algorithm.
Definition at line 220 of file fast_date.hpp.
|
inlinenoexcept |
Convert days since Unix epoch to year using a fast constexpr algorithm.
Definition at line 194 of file fast_date.hpp.
|
inlinestatic |
Fill an NTP client request packet using local time.
Definition at line 83 of file ntp_packet.hpp.
Definition at line 192 of file time_zone_conversions.hpp.
|
inlinenoexcept |
Floor division for positive divisor.
Definition at line 14 of file floor_math.hpp.
|
inlinenoexcept |
Floor-mod for positive modulus (returns r in [0..b)).
Definition at line 20 of file floor_math.hpp.
Definition at line 98 of file time_zone_conversions.hpp.
Definition at line 138 of file time_zone_conversions.hpp.
Definition at line 262 of file time_zone_conversions.hpp.
|
inlinenoexcept |
Definition at line 30 of file julian_conversions.hpp.
|
inlinenoexcept |
Definition at line 43 of file julian_conversions.hpp.
|
inlinenoexcept |
Check whether character is ASCII digit.
Definition at line 278 of file time_parser.hpp.
|
inlinenoexcept |
Check whether character is ASCII whitespace.
Definition at line 273 of file time_parser.hpp.
|
inline |
Definition at line 142 of file time_zone_conversions.hpp.
|
inlinenoexcept |
Definition at line 67 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Return the high 64 bits of a 64x64-bit multiplication.
Definition at line 35 of file mul_hi.hpp.
|
inlinenoexcept |
Return the high 64 bits of a 64x64-bit multiplication (constexpr variant).
Definition at line 19 of file mul_hi.hpp.
|
inlinenoexcept |
Alias for mul_hi_u64 used for shift-by-64 operations.
Definition at line 47 of file mul_hi.hpp.
|
inlinenoexcept |
Alias for mul_hi_u64_constexpr used for shift-by-64 operations.
Definition at line 52 of file mul_hi.hpp.
|
inline |
Normalize month token to lower-case ASCII using current locale facet.
| month | Input token. |
| output | Output lower-case token (overwritten). |
Definition at line 99 of file time_parser.hpp.
|
inline |
Normalize month token to lower-case ASCII using current locale facet (string_view).
| month | Input token view. |
| output | Output lower-case token (overwritten). |
Definition at line 112 of file time_parser.hpp.
|
inlinestaticnoexcept |
Convert NTP fractional seconds to microseconds.
Definition at line 68 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract leap indicator from LI/VN/Mode field.
Definition at line 53 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract mode from LI/VN/Mode field.
Definition at line 63 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Convert NTP timestamp parts to Unix microseconds.
Definition at line 74 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract version number from LI/VN/Mode field.
Definition at line 58 of file ntp_packet.hpp.
Definition at line 38 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Definition at line 33 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Definition at line 49 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Definition at line 60 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Definition at line 76 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Definition at line 42 of file ole_automation_conversions.hpp.
|
inlinenoexcept |
Parse exactly 2 digits into int.
Definition at line 291 of file time_parser.hpp.
|
inlinenoexcept |
Parse exactly 4 digits into year_t (via int).
Definition at line 307 of file time_parser.hpp.
|
inlinenoexcept |
Parse fractional seconds (1..9 digits) and convert to milliseconds.
Uses first 3 digits, scales if fewer.
Definition at line 324 of file time_parser.hpp.
|
inline |
Parse month name token into month index (1..12).
| month | Month token. |
| std::invalid_argument | if token is invalid. |
Definition at line 189 of file time_parser.hpp.
|
inline |
Parse month name token into month index (1..12), string_view overload.
| month | Month token view. |
| std::invalid_argument | if token is invalid. |
Definition at line 202 of file time_parser.hpp.
|
inlinestaticnoexcept |
Parse server response and compute offset and delay.
Definition at line 95 of file ntp_packet.hpp.
|
inlinenoexcept |
Skip ASCII whitespace.
Definition at line 283 of file time_parser.hpp.
Split UNIX seconds into whole days and seconds-of-day.
Definition at line 39 of file fast_date.hpp.
|
inlinenoexcept |
Return supported strict named-zone entries.
Definition at line 217 of file time_parser.hpp.
|
inline |
Trim ASCII whitespace from both ends.
Definition at line 77 of file time_parser.hpp.
|
inline |
Trim ASCII whitespace from both ends (string_view).
Definition at line 87 of file time_parser.hpp.
|
inline |
Try parse month name token into month index (1..12).
| month | Month token (e.g. "Jan", "January", case-insensitive). |
| value | Output month index in range [1..12]. |
Definition at line 127 of file time_parser.hpp.
|
inline |
Try parse month name token into month index (1..12), string_view overload.
| month | Month token view (e.g. "Jan", "January", case-insensitive). |
| value | Output month index in range [1..12]. |
Definition at line 158 of file time_parser.hpp.
|
inlinenoexcept |
Parse strict named-zone token without trimming.
Definition at line 249 of file time_parser.hpp.
Definition at line 249 of file time_zone_conversions.hpp.