Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_zone_offset.hpp File Reference

UTC offset arithmetic helpers (UTC <-> local) and TimeZoneStruct offset extraction. More...

Go to the source code of this file.

Namespaces

namespace  time_shield
 Main namespace for the Time Shield library.
 

Functions

TIME_SHIELD_CONSTEXPR ts_t time_shield::to_utc (ts_t local, tz_t utc_offset) noexcept
 Convert local timestamp (seconds) to UTC using UTC offset.
 
TIME_SHIELD_CONSTEXPR ts_t time_shield::to_local (ts_t utc, tz_t utc_offset) noexcept
 Convert UTC timestamp (seconds) to local time using UTC offset.
 
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::to_utc_ms (ts_ms_t local_ms, tz_t utc_offset) noexcept
 Convert local timestamp (milliseconds) to UTC using UTC offset.
 
TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::to_local_ms (ts_ms_t utc_ms, tz_t utc_offset) noexcept
 Convert UTC timestamp (milliseconds) to local time using UTC offset.
 
TIME_SHIELD_CONSTEXPR tz_t time_shield::utc_offset_of (const TimeZoneStruct &tz) noexcept
 Extract numeric UTC offset (in seconds) from TimeZoneStruct.
 

Detailed Description

UTC offset arithmetic helpers (UTC <-> local) and TimeZoneStruct offset extraction.

This header provides simple, allocation-free conversions between:

  • UTC timestamp and local timestamp using a numeric UTC offset (in seconds).
  • UTC milliseconds and local milliseconds using the same offset.
Note
The offset is interpreted as an UTC offset in seconds, i.e.: local = utc + utc_offset utc = local - utc_offset
If the input equals ERROR_TIMESTAMP, the functions return ERROR_TIMESTAMP unchanged.

Definition in file time_zone_offset.hpp.