3#ifndef _TIME_SHIELD_TIME_ZONE_CONVERSIONS_HPP_INCLUDED
4#define _TIME_SHIELD_TIME_ZONE_CONVERSIONS_HPP_INCLUDED
28 const int OLD_START_SUMMER_HOUR = 2;
29 const int OLD_STOP_SUMMER_HOUR = 3;
30 const int NEW_SUMMER_HOUR = 1;
36 for(
int d = max_days; d >= dt.
day; --d) {
39 if(dt.
hour >= OLD_START_SUMMER_HOUR) {
49 for(
int d = max_days; d >= dt.
day; --d) {
52 if(dt.
hour >= OLD_STOP_SUMMER_HOUR) {
69 for(
int d = max_days; d >= dt.
day; --d) {
72 if(dt.
hour >= (NEW_SUMMER_HOUR + 2)) {
83 for(
int d = max_days; d >= dt.
day; --d) {
86 if(dt.
hour >= (NEW_SUMMER_HOUR + 1)) {
100 const int SWITCH_HOUR = 1;
113 if(dt.
hour >= SWITCH_HOUR) {
126 if(dt.
hour >= SWITCH_HOUR) {
143 const int SWITCH_HOUR = 2;
149 if(dt.
year >= 2007) {
152 int first_sunday_march =
static_cast<int>(
154 start_day = first_sunday_march + 7;
155 end_day =
static_cast<int>(
160 start_day =
static_cast<int>(
165 if(dt.
mon > start_month && dt.
mon < end_month) {
168 if(dt.
mon < start_month || dt.
mon > end_month) {
171 if(dt.
mon == start_month) {
172 if(dt.
day > start_day) {
175 if(dt.
day < start_day) {
178 return dt.
hour >= SWITCH_HOUR;
180 if(dt.
mon == end_month) {
181 if(dt.
day < end_day) {
184 if(dt.
day > end_day) {
187 return dt.
hour < SWITCH_HOUR;
383 return to_utc(local, utc_offset);
392 return to_utc(local, utc_offset);
Header for date and time structure and related functions.
constexpr int64_t ERROR_TIMESTAMP
Error timestamp value.
constexpr int64_t DAYS_PER_WEEK
Days per week.
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
constexpr int64_t SEC_PER_MIN
Seconds per minute.
ts_t gmt_to_et(ts_t gmt)
Convert GMT (UTC) to US Eastern Time (New York, EST/EDT).
ts_t kzt_to_gmt(ts_t kzt)
ts_t eet_to_gmt(ts_t eet)
Convert Eastern European Time to Greenwich Mean Time.
ts_t gmt_to_gst(ts_t gmt)
ts_t gmt_to_hkt(ts_t gmt)
ts_t gmt_to_eet(ts_t gmt)
Convert Greenwich Mean Time to Eastern European Time.
ts_t gst_to_gmt(ts_t gst)
ts_t byt_to_gmt(ts_t byt)
ts_ms_t zone_to_gmt_ms(ts_ms_t local_ms, TimeZone zone)
Convert supported local civil time in milliseconds to GMT (UTC).
ts_t gmt_to_kyiv(ts_t gmt)
Convert GMT to Kyiv civil time using the EET/EEST rules.
ts_t gmt_to_ist(ts_t gmt)
ts_t ct_to_gmt(ts_t ct)
Convert US Central Time (America/Chicago, CST/CDT) to GMT (UTC).
ts_t gmt_to_jst(ts_t gmt)
bool is_us_eastern_dst_local(const DateTimeStruct &dt)
Check if local US Eastern time uses DST.
ts_t ict_to_gmt(ts_t ict)
ts_t gmt_to_wit(ts_t gmt)
TIME_SHIELD_CONSTEXPR ts_t to_utc(ts_t local, tz_t utc_offset) noexcept
Convert local timestamp (seconds) to UTC using UTC offset.
ts_t gmt_to_kzt(ts_t gmt)
ts_t kyiv_to_gmt(ts_t kyiv)
Convert Kyiv civil time to GMT using the EET/EEST rules.
ts_t wita_to_gmt(ts_t wita)
ts_t cet_to_gmt(ts_t cet)
Convert Central European Time to Greenwich Mean Time.
ts_t convert_time_zone(ts_t local, TimeZone from, TimeZone to)
Convert a timestamp between two supported local civil time zones.
ts_t gmt_to_byt(ts_t gmt)
ts_ms_t gmt_to_zone_ms(ts_ms_t gmt_ms, TimeZone zone)
Convert GMT (UTC) in milliseconds to a supported local civil time zone.
ts_t gmt_to_pht(ts_t gmt)
TIME_SHIELD_CONSTEXPR ts_t to_local(ts_t utc, tz_t utc_offset) noexcept
Convert UTC timestamp (seconds) to local time using UTC offset.
ts_t gmt_to_ny(ts_t gmt)
Convert GMT (UTC) to New York Time.
ts_t gmt_to_cet(ts_t gmt)
Convert Greenwich Mean Time to Central European Time.
ts_t gmt_to_sgt(ts_t gmt)
ts_t kst_to_gmt(ts_t kst)
ts_t gmt_to_trt(ts_t gmt)
TIME_SHIELD_CONSTEXPR ts_ms_t to_local_ms(ts_ms_t utc_ms, tz_t utc_offset) noexcept
Convert UTC timestamp (milliseconds) to local time using UTC offset.
ts_t zone_to_gmt(ts_t local, TimeZone zone)
Convert supported local civil time to GMT (UTC).
ts_t wit_to_gmt(ts_t wit)
ts_t hkt_to_gmt(ts_t hkt)
ts_t gmt_to_ict(ts_t gmt)
ts_t ist_to_gmt(ts_t ist)
ts_t gmt_to_wib(ts_t gmt)
ts_t gmt_to_myt(ts_t gmt)
ts_t wib_to_gmt(ts_t wib)
ts_t trt_to_gmt(ts_t trt)
ts_t gmt_to_zone(ts_t gmt, TimeZone zone)
Convert GMT (UTC) to a supported local civil time zone.
ts_t pht_to_gmt(ts_t pht)
ts_t sgt_to_gmt(ts_t sgt)
ts_t ny_to_gmt(ts_t ny)
Convert New York Time to GMT (UTC).
ts_t gmt_to_wita(ts_t gmt)
ts_t et_to_gmt(ts_t et)
Convert US Eastern Time (New York, EST/EDT) to GMT (UTC).
ts_ms_t 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 gmt_to_ct(ts_t gmt)
Convert GMT (UTC) to US Central Time (America/Chicago, CST/CDT).
TIME_SHIELD_CONSTEXPR ts_ms_t to_utc_ms(ts_ms_t local_ms, tz_t utc_offset) noexcept
Convert local timestamp (milliseconds) to UTC using UTC offset.
ts_t gmt_to_kst(ts_t gmt)
ts_t jst_to_gmt(ts_t jst)
ts_t myt_to_gmt(ts_t myt)
TIME_SHIELD_CONSTEXPR T1 ms_to_sec(T2 ts_ms) noexcept
Converts a timestamp from milliseconds to seconds.
TIME_SHIELD_CONSTEXPR T1 day_of_week_date(T2 year, T3 month, T4 day)
Get the day of the week.
TIME_SHIELD_CONSTEXPR T1 sec_to_ms(T2 ts) noexcept
Converts a timestamp from seconds to milliseconds.
@ JST
Japan Standard Time.
@ KST
Korea Standard Time.
@ EET
Eastern European Time.
@ CEST
Central European Summer Time.
@ WIT
Eastern Indonesia Time.
@ WEST
Western European Summer Time.
@ WITA
Central Indonesia Time.
@ WET
Western European Time.
@ UNKNOWN
Unknown Time Zone.
@ UTC
Coordinated Universal Time.
@ GMT
Greenwich Mean Time.
@ WIB
Western Indonesia Time.
@ EEST
Eastern European Summer Time.
@ CET
Central European Time.
@ IST
India Standard Time.
TIME_SHIELD_CONSTEXPR T1 last_sunday_month_day(T2 year, T3 month)
Get the day of the last Sunday of the given month and year.
T1 to_date_time(T2 ts)
Converts a timestamp to a date-time structure.
TIME_SHIELD_CONSTEXPR T1 num_days_in_month(T2 year, T3 month) noexcept
Get the number of days in a month.
int64_t ts_t
Unix timestamp in seconds since 1970‑01‑01T00:00:00Z.
int32_t tz_t
Time zone offset in minutes from UTC (e.g., +180 = UTC+3).
int64_t ts_ms_t
Unix timestamp in milliseconds since epoch.
bool fixed_zone_offset(TimeZone zone, tz_t &utc_offset)
ts_t gmt_to_cet_impl(ts_t gmt)
ts_t cet_to_gmt_impl(ts_t cet)
ts_t gmt_to_european_local(ts_t gmt, int standard_offset_hours)
bool is_us_eastern_dst_local(const DateTimeStruct &dt)
ts_ms_t gmt_to_zone_ms_by_seconds(ts_ms_t gmt_ms, TimeZone zone)
ts_t european_local_to_gmt(ts_t local, int standard_offset_hours)
ts_ms_t zone_to_gmt_ms_by_seconds(ts_ms_t local_ms, TimeZone zone)
Main namespace for the Time Shield library.
Structure to represent date and time.
int hour
Hour component of time (0-23).
int64_t year
Year component of the date.
int day
Day component of the date (1-31).
int mon
Month component of the date (1-12).
Umbrella header for time conversion functions.
Helper functions for unit conversions between seconds, minutes, hours, and milliseconds.
UTC offset arithmetic helpers (UTC <-> local) and TimeZoneStruct offset extraction.