Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
Time zone conversion helpers
ts_t time_shield::zone_to_gmt (ts_t local, TimeZone zone)
 Convert supported local civil time to GMT (UTC).
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

Function Documentation

◆ to_local()

TIME_SHIELD_CONSTEXPR ts_t time_shield::to_local ( ts_t utc,
tz_t utc_offset )
inlinenoexcept

Convert UTC timestamp (seconds) to local time using UTC offset.

Parameters
utcUTC timestamp in seconds.
utc_offsetUTC offset in seconds (e.g. CET=+3600, MSK=+10800, EST=-18000).
Returns
Local timestamp in seconds. If utc equals ERROR_TIMESTAMP, returns ERROR_TIMESTAMP.

Definition at line 43 of file time_zone_offset.hpp.

◆ to_local_ms()

TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::to_local_ms ( ts_ms_t utc_ms,
tz_t utc_offset )
inlinenoexcept

Convert UTC timestamp (milliseconds) to local time using UTC offset.

Parameters
utc_msUTC timestamp in milliseconds.
utc_offsetUTC offset in seconds (will be converted to milliseconds).
Returns
Local timestamp in milliseconds. If utc_ms equals ERROR_TIMESTAMP, returns ERROR_TIMESTAMP.

Definition at line 61 of file time_zone_offset.hpp.

◆ to_utc()

TIME_SHIELD_CONSTEXPR ts_t time_shield::to_utc ( ts_t local,
tz_t utc_offset )
inlinenoexcept

Convert local timestamp (seconds) to UTC using UTC offset.

Parameters
localLocal timestamp in seconds.
utc_offsetUTC offset in seconds (e.g. CET=+3600, MSK=+10800, EST=-18000).
Returns
UTC timestamp in seconds. If local equals ERROR_TIMESTAMP, returns ERROR_TIMESTAMP.

Definition at line 34 of file time_zone_offset.hpp.

◆ to_utc_ms()

TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::to_utc_ms ( ts_ms_t local_ms,
tz_t utc_offset )
inlinenoexcept

Convert local timestamp (milliseconds) to UTC using UTC offset.

Parameters
local_msLocal timestamp in milliseconds.
utc_offsetUTC offset in seconds (will be converted to milliseconds).
Returns
UTC timestamp in milliseconds. If local_ms equals ERROR_TIMESTAMP, returns ERROR_TIMESTAMP.

Definition at line 52 of file time_zone_offset.hpp.

◆ utc_offset_of()

TIME_SHIELD_CONSTEXPR tz_t time_shield::utc_offset_of ( const TimeZoneStruct & tz)
inlinenoexcept

Extract numeric UTC offset (in seconds) from TimeZoneStruct.

Parameters
tzTime zone descriptor.
Returns
UTC offset in seconds (local = utc + offset).

Definition at line 69 of file time_zone_offset.hpp.

◆ zone_to_gmt()

ts_t time_shield::zone_to_gmt ( ts_t local,
TimeZone zone )
inline

Convert supported local civil time to GMT (UTC).

Parameters
localTimestamp in seconds in the source time zone.
zoneSource time zone.
Returns
Timestamp in seconds in GMT, or ERROR_TIMESTAMP for unsupported zones.

Definition at line 394 of file time_zone_conversions.hpp.