7#ifndef __TIME_SHIELD_TIME_ZONE_CONVERSIONS_MQH__
8#define __TIME_SHIELD_TIME_ZONE_CONVERSIONS_MQH__
14#property copyright "Copyright 2025, NewYaroslav"
15#property link "https://github.com/NewYaroslav/time-shield-cpp"
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 =
154 start_day = first_sunday_march + 7;
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;
284 datetime et_standard = gmt - (datetime)
SEC_PER_HOUR * 5;
336 return local - (datetime)utc_offset;
345 return local - (datetime)utc_offset;
373 return gmt + (datetime)utc_offset;
382 return gmt + (datetime)utc_offset;
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_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)
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_t gmt_to_pht(ts_t gmt)
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)
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_t gmt_to_ct(ts_t gmt)
Convert GMT (UTC) to US Central Time (America/Chicago, CST/CDT).
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 day_of_week_date(T2 year, T3 month, T4 day)
Get the day of the week.
@ 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.
Main namespace for the Time Shield library.
bool fixed_zone_offset(const TimeZone zone, long &utc_offset)
datetime gmt_to_european_local(const datetime gmt, const int standard_offset_hours)
datetime gmt_to_cet_impl(const datetime gmt)
datetime european_local_to_gmt(const datetime local, const int standard_offset_hours)
datetime cet_to_gmt_impl(const datetime cet)
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).
Header with helper functions for converting between different time representations in MQL5.