Time Shield Library 2.0.0
C++ library for working with time
Loading...
Searching...
No Matches
test_time_zone_matrix.mq5
Go to the documentation of this file.
1//+------------------------------------------------------------------+
2//| test_time_zone_matrix.mq5 |
3//| Time Shield - Function Test |
4//| Copyright 2025, NewYaroslav |
5//| https://github.com/LimiNode/time-shield-cpp |
6//+------------------------------------------------------------------+
7#property script_show_inputs
8#property strict
9
10#include <TimeShield.mqh>
11
12void OnStart() {
13 time_shield::init();
14 bool is_ok = true;
15
16 datetime ist_local = (datetime)time_shield::to_ts(2024, time_shield::JUL, 15, 12, 0, 0);
17 datetime expected_gmt = (datetime)time_shield::to_ts(2024, time_shield::JUL, 15, 6, 30, 0);
18 datetime gmt_from_ist = time_shield::ist_to_gmt(ist_local);
19 if(gmt_from_ist == expected_gmt)
20 Print("IST -> GMT passed");
21 else {
22 Print("IST -> GMT failed: ", gmt_from_ist, " != ", expected_gmt);
23 is_ok = false;
24 }
25
26 datetime myt_from_ist = time_shield::convert_time_zone(ist_local, time_shield::IST, time_shield::MYT);
27 datetime expected_myt = (datetime)time_shield::to_ts(2024, time_shield::JUL, 15, 14, 30, 0);
28 if(myt_from_ist == expected_myt)
29 Print("IST -> MYT passed");
30 else {
31 Print("IST -> MYT failed: ", myt_from_ist, " != ", expected_myt);
32 is_ok = false;
33 }
34
35 datetime kyiv_local = (datetime)time_shield::to_ts(2024, time_shield::JUL, 15, 12, 0, 0);
36 if(time_shield::kyiv_to_gmt(kyiv_local) == time_shield::eet_to_gmt(kyiv_local))
37 Print("Kyiv alias passed");
38 else {
39 Print("Kyiv alias failed");
40 is_ok = false;
41 }
42
43 Print(is_ok ? "Time zone matrix tests passed" : "Time zone matrix tests failed");
44}