3#ifndef _TIME_SHIELD_TIME_ZONE_CONVERSIONS_HPP_INCLUDED
4#define _TIME_SHIELD_TIME_ZONE_CONVERSIONS_HPP_INCLUDED
24 const int OLD_START_SUMMER_HOUR = 2;
25 const int OLD_STOP_SUMMER_HOUR = 3;
26 const int NEW_SUMMER_HOUR = 1;
33 for(
int d = max_days; d >= dt.
day; --d) {
36 if(dt.
hour >= OLD_START_SUMMER_HOUR)
45 for(
int d = max_days; d >= dt.
day; --d) {
48 if(dt.
hour >= OLD_STOP_SUMMER_HOUR)
63 for(
int d = max_days; d >= dt.
day; --d) {
66 if(dt.
hour >= (NEW_SUMMER_HOUR + 2))
76 for(
int d = max_days; d >= dt.
day; --d) {
79 if(dt.
hour >= (NEW_SUMMER_HOUR + 1))
102 const int SWITCH_HOUR = 2;
108 if(dt.
year >= 2007) {
111 int first_sunday_march =
static_cast<int>(
113 start_day = first_sunday_march + 7;
114 end_day =
static_cast<int>(
119 start_day =
static_cast<int>(
124 if(dt.
mon > start_month && dt.
mon < end_month) {
127 if(dt.
mon < start_month || dt.
mon > end_month) {
130 if(dt.
mon == start_month) {
131 if(dt.
day > start_day) {
134 if(dt.
day < start_day) {
137 return dt.
hour >= SWITCH_HOUR;
139 if(dt.
mon == end_month) {
140 if(dt.
day < end_day) {
143 if(dt.
day > end_day) {
146 return dt.
hour < SWITCH_HOUR;
209 const int SWITCH_HOUR = 1;
213 }
else if(dt.
mon ==
MAR) {
217 }
else if(dt.
day < last) {
220 if(dt.
hour >= SWITCH_HOUR)
224 }
else if(dt.
mon ==
OCT) {
228 }
else if(dt.
day < last) {
231 if(dt.
hour >= SWITCH_HOUR)
Header for date and time structure and related functions.
constexpr int64_t DAYS_PER_WEEK
Days per week.
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
ts_t gmt_to_et(ts_t gmt)
Convert GMT (UTC) to US Eastern Time (New York, EST/EDT).
ts_t eet_to_gmt(ts_t eet)
Convert Eastern European Time to Greenwich Mean Time.
ts_t gmt_to_eet(ts_t gmt)
Convert Greenwich Mean Time to Eastern European Time.
ts_t ct_to_gmt(ts_t ct)
Convert US Central Time (America/Chicago, CST/CDT) to GMT (UTC).
bool is_us_eastern_dst_local(const DateTimeStruct &dt)
Check if local US Eastern time uses DST.
ts_t cet_to_gmt(ts_t cet)
Convert Central European Time to Greenwich Mean Time.
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 ny_to_gmt(ts_t ny)
Convert New York Time to GMT (UTC).
ts_t et_to_gmt(ts_t et)
Convert US Eastern Time (New York, EST/EDT) to GMT (UTC).
ts_t gmt_to_ct(ts_t gmt)
Convert GMT (UTC) to US Central Time (America/Chicago, CST/CDT).
TIME_SHIELD_CONSTEXPR T1 day_of_week_date(T2 year, T3 month, T4 day)
Get the day of the week.
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.
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.