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).
ts_t time_shield::gmt_to_zone (ts_t gmt, TimeZone zone)
 Convert GMT (UTC) to a supported local civil time zone.
ts_t time_shield::cet_to_gmt (ts_t cet)
 Convert Central European Time to Greenwich Mean Time.
ts_t time_shield::eet_to_gmt (ts_t eet)
 Convert Eastern European Time to Greenwich Mean Time.
bool time_shield::is_us_eastern_dst_local (const DateTimeStruct &dt)
 Check if local US Eastern time uses DST.
ts_t time_shield::et_to_gmt (ts_t et)
 Convert US Eastern Time (New York, EST/EDT) to GMT (UTC).
ts_t time_shield::gmt_to_et (ts_t gmt)
 Convert GMT (UTC) to US Eastern Time (New York, EST/EDT).
ts_t time_shield::ny_to_gmt (ts_t ny)
 Convert New York Time to GMT (UTC).
ts_t time_shield::gmt_to_ny (ts_t gmt)
 Convert GMT (UTC) to New York Time.
ts_t time_shield::ct_to_gmt (ts_t ct)
 Convert US Central Time (America/Chicago, CST/CDT) to GMT (UTC).
ts_t time_shield::gmt_to_ct (ts_t gmt)
 Convert GMT (UTC) to US Central Time (America/Chicago, CST/CDT).
ts_t time_shield::gmt_to_cet (ts_t gmt)
 Convert Greenwich Mean Time to Central European Time.
ts_t time_shield::gmt_to_eet (ts_t gmt)
 Convert Greenwich Mean Time to Eastern European Time.
ts_t time_shield::convert_time_zone (ts_t local, TimeZone from, TimeZone to)
 Convert a timestamp between two supported local civil time zones.
ts_ms_t time_shield::zone_to_gmt_ms (ts_ms_t local_ms, TimeZone zone)
 Convert supported local civil time in milliseconds to GMT (UTC).
ts_ms_t time_shield::gmt_to_zone_ms (ts_ms_t gmt_ms, TimeZone zone)
 Convert GMT (UTC) in milliseconds to a supported local civil time zone.
ts_ms_t time_shield::convert_time_zone_ms (ts_ms_t local_ms, TimeZone from, TimeZone to)
 Convert a millisecond timestamp between two supported local civil time zones.
ts_t time_shield::ist_to_gmt (ts_t ist)
ts_t time_shield::gmt_to_ist (ts_t gmt)
ts_t time_shield::myt_to_gmt (ts_t myt)
ts_t time_shield::gmt_to_myt (ts_t gmt)
ts_t time_shield::wib_to_gmt (ts_t wib)
ts_t time_shield::gmt_to_wib (ts_t gmt)
ts_t time_shield::wita_to_gmt (ts_t wita)
ts_t time_shield::gmt_to_wita (ts_t gmt)
ts_t time_shield::wit_to_gmt (ts_t wit)
ts_t time_shield::gmt_to_wit (ts_t gmt)
ts_t time_shield::kzt_to_gmt (ts_t kzt)
ts_t time_shield::gmt_to_kzt (ts_t gmt)
ts_t time_shield::trt_to_gmt (ts_t trt)
ts_t time_shield::gmt_to_trt (ts_t gmt)
ts_t time_shield::byt_to_gmt (ts_t byt)
ts_t time_shield::gmt_to_byt (ts_t gmt)
ts_t time_shield::sgt_to_gmt (ts_t sgt)
ts_t time_shield::gmt_to_sgt (ts_t gmt)
ts_t time_shield::ict_to_gmt (ts_t ict)
ts_t time_shield::gmt_to_ict (ts_t gmt)
ts_t time_shield::pht_to_gmt (ts_t pht)
ts_t time_shield::gmt_to_pht (ts_t gmt)
ts_t time_shield::gst_to_gmt (ts_t gst)
ts_t time_shield::gmt_to_gst (ts_t gmt)
ts_t time_shield::hkt_to_gmt (ts_t hkt)
ts_t time_shield::gmt_to_hkt (ts_t gmt)
ts_t time_shield::jst_to_gmt (ts_t jst)
ts_t time_shield::gmt_to_jst (ts_t gmt)
ts_t time_shield::kst_to_gmt (ts_t kst)
ts_t time_shield::gmt_to_kst (ts_t gmt)
ts_t time_shield::kyiv_to_gmt (ts_t kyiv)
 Convert Kyiv civil time to GMT using the EET/EEST rules.
ts_t time_shield::gmt_to_kyiv (ts_t gmt)
 Convert GMT to Kyiv civil time using the EET/EEST rules.
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

◆ byt_to_gmt()

ts_t time_shield::byt_to_gmt ( ts_t byt)
inline

Definition at line 550 of file time_zone_conversions.hpp.

◆ cet_to_gmt()

ts_t time_shield::cet_to_gmt ( ts_t cet)
inline

Convert Central European Time to Greenwich Mean Time.

Parameters
cetTimestamp in seconds in CET/CEST.
Returns
Timestamp in seconds in GMT.

Definition at line 280 of file time_zone_conversions.hpp.

◆ convert_time_zone()

ts_t time_shield::convert_time_zone ( ts_t local,
TimeZone from,
TimeZone to )
inline

Convert a timestamp between two supported local civil time zones.

Parameters
localTimestamp in seconds in the source time zone.
fromSource time zone.
toDestination time zone.
Returns
Timestamp in seconds in the destination time zone, or ERROR_TIMESTAMP on failure.

Definition at line 442 of file time_zone_conversions.hpp.

◆ convert_time_zone_ms()

ts_ms_t time_shield::convert_time_zone_ms ( ts_ms_t local_ms,
TimeZone from,
TimeZone to )
inline

Convert a millisecond timestamp between two supported local civil time zones.

Parameters
local_msTimestamp in milliseconds in the source time zone.
fromSource time zone.
toDestination time zone.
Returns
Timestamp in milliseconds in the destination time zone, or ERROR_TIMESTAMP on failure.

Definition at line 523 of file time_zone_conversions.hpp.

◆ ct_to_gmt()

ts_t time_shield::ct_to_gmt ( ts_t ct)
inline

Convert US Central Time (America/Chicago, CST/CDT) to GMT (UTC).

Parameters
ctTimestamp in seconds in CT.
Returns
Timestamp in seconds in GMT (UTC).

Definition at line 334 of file time_zone_conversions.hpp.

◆ eet_to_gmt()

ts_t time_shield::eet_to_gmt ( ts_t eet)
inline

Convert Eastern European Time to Greenwich Mean Time.

Parameters
eetTimestamp in seconds in EET/EEST.
Returns
Timestamp in seconds in GMT.

Definition at line 287 of file time_zone_conversions.hpp.

◆ et_to_gmt()

ts_t time_shield::et_to_gmt ( ts_t et)
inline

Convert US Eastern Time (New York, EST/EDT) to GMT (UTC).

Parameters
etTimestamp in seconds in ET.
Returns
Timestamp in seconds in GMT (UTC).

Definition at line 301 of file time_zone_conversions.hpp.

◆ gmt_to_byt()

ts_t time_shield::gmt_to_byt ( ts_t gmt)
inline

Definition at line 551 of file time_zone_conversions.hpp.

◆ gmt_to_cet()

ts_t time_shield::gmt_to_cet ( ts_t gmt)
inline

Convert Greenwich Mean Time to Central European Time.

Parameters
gmtTimestamp in seconds in GMT.
Returns
Timestamp in seconds in CET/CEST.

Definition at line 348 of file time_zone_conversions.hpp.

◆ gmt_to_ct()

ts_t time_shield::gmt_to_ct ( ts_t gmt)
inline

Convert GMT (UTC) to US Central Time (America/Chicago, CST/CDT).

Parameters
gmtTimestamp in seconds in GMT (UTC).
Returns
Timestamp in seconds in CT.

Definition at line 341 of file time_zone_conversions.hpp.

◆ gmt_to_eet()

ts_t time_shield::gmt_to_eet ( ts_t gmt)
inline

Convert Greenwich Mean Time to Eastern European Time.

Parameters
gmtTimestamp in seconds in GMT.
Returns
Timestamp in seconds in EET/EEST.

Definition at line 355 of file time_zone_conversions.hpp.

◆ gmt_to_et()

ts_t time_shield::gmt_to_et ( ts_t gmt)
inline

Convert GMT (UTC) to US Eastern Time (New York, EST/EDT).

Parameters
gmtTimestamp in seconds in GMT (UTC).
Returns
Timestamp in seconds in ET.

Definition at line 310 of file time_zone_conversions.hpp.

◆ gmt_to_gst()

ts_t time_shield::gmt_to_gst ( ts_t gmt)
inline

Definition at line 563 of file time_zone_conversions.hpp.

◆ gmt_to_hkt()

ts_t time_shield::gmt_to_hkt ( ts_t gmt)
inline

Definition at line 566 of file time_zone_conversions.hpp.

◆ gmt_to_ict()

ts_t time_shield::gmt_to_ict ( ts_t gmt)
inline

Definition at line 557 of file time_zone_conversions.hpp.

◆ gmt_to_ist()

ts_t time_shield::gmt_to_ist ( ts_t gmt)
inline

Definition at line 530 of file time_zone_conversions.hpp.

◆ gmt_to_jst()

ts_t time_shield::gmt_to_jst ( ts_t gmt)
inline

Definition at line 569 of file time_zone_conversions.hpp.

◆ gmt_to_kst()

ts_t time_shield::gmt_to_kst ( ts_t gmt)
inline

Definition at line 572 of file time_zone_conversions.hpp.

◆ gmt_to_kyiv()

ts_t time_shield::gmt_to_kyiv ( ts_t gmt)
inline

Convert GMT to Kyiv civil time using the EET/EEST rules.

Definition at line 578 of file time_zone_conversions.hpp.

◆ gmt_to_kzt()

ts_t time_shield::gmt_to_kzt ( ts_t gmt)
inline

Definition at line 545 of file time_zone_conversions.hpp.

◆ gmt_to_myt()

ts_t time_shield::gmt_to_myt ( ts_t gmt)
inline

Definition at line 533 of file time_zone_conversions.hpp.

◆ gmt_to_ny()

ts_t time_shield::gmt_to_ny ( ts_t gmt)
inline

Convert GMT (UTC) to New York Time.

Parameters
gmtTimestamp in seconds in GMT (UTC).
Returns
Timestamp in seconds in ET.

Definition at line 327 of file time_zone_conversions.hpp.

◆ gmt_to_pht()

ts_t time_shield::gmt_to_pht ( ts_t gmt)
inline

Definition at line 560 of file time_zone_conversions.hpp.

◆ gmt_to_sgt()

ts_t time_shield::gmt_to_sgt ( ts_t gmt)
inline

Definition at line 554 of file time_zone_conversions.hpp.

◆ gmt_to_trt()

ts_t time_shield::gmt_to_trt ( ts_t gmt)
inline

Definition at line 548 of file time_zone_conversions.hpp.

◆ gmt_to_wib()

ts_t time_shield::gmt_to_wib ( ts_t gmt)
inline

Definition at line 536 of file time_zone_conversions.hpp.

◆ gmt_to_wit()

ts_t time_shield::gmt_to_wit ( ts_t gmt)
inline

Definition at line 542 of file time_zone_conversions.hpp.

◆ gmt_to_wita()

ts_t time_shield::gmt_to_wita ( ts_t gmt)
inline

Definition at line 539 of file time_zone_conversions.hpp.

◆ gmt_to_zone()

ts_t time_shield::gmt_to_zone ( ts_t gmt,
TimeZone zone )
inline

Convert GMT (UTC) to a supported local civil time zone.

Parameters
gmtTimestamp in seconds in GMT (UTC).
zoneDestination time zone.
Returns
Timestamp in seconds in the destination time zone, or ERROR_TIMESTAMP for unsupported zones.

Definition at line 402 of file time_zone_conversions.hpp.

◆ gmt_to_zone_ms()

ts_ms_t time_shield::gmt_to_zone_ms ( ts_ms_t gmt_ms,
TimeZone zone )
inline

Convert GMT (UTC) in milliseconds to a supported local civil time zone.

Parameters
gmt_msTimestamp in milliseconds in GMT (UTC).
zoneDestination time zone.
Returns
Timestamp in milliseconds in the destination time zone, or ERROR_TIMESTAMP for unsupported zones.

Definition at line 487 of file time_zone_conversions.hpp.

◆ gst_to_gmt()

ts_t time_shield::gst_to_gmt ( ts_t gst)
inline

Definition at line 562 of file time_zone_conversions.hpp.

◆ hkt_to_gmt()

ts_t time_shield::hkt_to_gmt ( ts_t hkt)
inline

Definition at line 565 of file time_zone_conversions.hpp.

◆ ict_to_gmt()

ts_t time_shield::ict_to_gmt ( ts_t ict)
inline

Definition at line 556 of file time_zone_conversions.hpp.

◆ is_us_eastern_dst_local()

bool time_shield::is_us_eastern_dst_local ( const DateTimeStruct & dt)
inline

Check if local US Eastern time uses DST.

Parameters
dtLocal time in ET.
Returns
True if DST applies for the provided local timestamp.

Definition at line 294 of file time_zone_conversions.hpp.

◆ ist_to_gmt()

ts_t time_shield::ist_to_gmt ( ts_t ist)
inline

Definition at line 529 of file time_zone_conversions.hpp.

◆ jst_to_gmt()

ts_t time_shield::jst_to_gmt ( ts_t jst)
inline

Definition at line 568 of file time_zone_conversions.hpp.

◆ kst_to_gmt()

ts_t time_shield::kst_to_gmt ( ts_t kst)
inline

Definition at line 571 of file time_zone_conversions.hpp.

◆ kyiv_to_gmt()

ts_t time_shield::kyiv_to_gmt ( ts_t kyiv)
inline

Convert Kyiv civil time to GMT using the EET/EEST rules.

Definition at line 575 of file time_zone_conversions.hpp.

◆ kzt_to_gmt()

ts_t time_shield::kzt_to_gmt ( ts_t kzt)
inline

Definition at line 544 of file time_zone_conversions.hpp.

◆ myt_to_gmt()

ts_t time_shield::myt_to_gmt ( ts_t myt)
inline

Definition at line 532 of file time_zone_conversions.hpp.

◆ ny_to_gmt()

ts_t time_shield::ny_to_gmt ( ts_t ny)
inline

Convert New York Time to GMT (UTC).

Parameters
nyTimestamp in seconds in ET.
Returns
Timestamp in seconds in GMT (UTC).

Definition at line 320 of file time_zone_conversions.hpp.

◆ pht_to_gmt()

ts_t time_shield::pht_to_gmt ( ts_t pht)
inline

Definition at line 559 of file time_zone_conversions.hpp.

◆ sgt_to_gmt()

ts_t time_shield::sgt_to_gmt ( ts_t sgt)
inline

Definition at line 553 of file time_zone_conversions.hpp.

◆ 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.

◆ trt_to_gmt()

ts_t time_shield::trt_to_gmt ( ts_t trt)
inline

Definition at line 547 of file time_zone_conversions.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.

◆ wib_to_gmt()

ts_t time_shield::wib_to_gmt ( ts_t wib)
inline

Definition at line 535 of file time_zone_conversions.hpp.

◆ wit_to_gmt()

ts_t time_shield::wit_to_gmt ( ts_t wit)
inline

Definition at line 541 of file time_zone_conversions.hpp.

◆ wita_to_gmt()

ts_t time_shield::wita_to_gmt ( ts_t wita)
inline

Definition at line 538 of file time_zone_conversions.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 363 of file time_zone_conversions.hpp.

◆ zone_to_gmt_ms()

ts_ms_t time_shield::zone_to_gmt_ms ( ts_ms_t local_ms,
TimeZone zone )
inline

Convert supported local civil time in milliseconds to GMT (UTC).

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

Definition at line 452 of file time_zone_conversions.hpp.