Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_zone_conversions_example.cpp
Go to the documentation of this file.
1
3
4#include <iostream>
5
8
9int main() {
10 using namespace time_shield;
11
12 // Fixed-offset example: convert GMT to India Standard Time.
13 ts_t gmt = to_timestamp(2024, int(Month::JUN), 21, 12, 0, 0);
14 ts_t ist = gmt_to_ist(gmt);
15
16 // Regional alias example: Kyiv uses the EET/EEST conversion rules.
17 ts_t kyiv = gmt_to_kyiv(gmt);
18
19 // Generic matrix example: convert IST local time directly to Malaysia time.
20 ts_t ist_local = to_timestamp(2024, int(Month::JUN), 21, 17, 30, 0);
21 ts_t myt_local = convert_time_zone(ist_local, TimeZone::IST, TimeZone::MYT);
22
23 std::cout << "GMT: " << to_iso8601(gmt) << '\n';
24 std::cout << "IST from GMT: " << to_iso8601(ist) << '\n';
25 std::cout << "Kyiv from GMT: " << to_iso8601(kyiv) << '\n';
26 std::cout << "MYT from IST local: " << to_iso8601(myt_local) << '\n';
27
28 return 0;
29}
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 convert_time_zone(ts_t local, TimeZone from, TimeZone to)
Convert a timestamp between two supported local civil time zones.
const std::string to_iso8601(T ts)
Converts a timestamp to an ISO8601 string.
TIME_SHIELD_CONSTEXPR ts_t to_timestamp(T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0)
Converts a date and time to a timestamp.
int64_t ts_t
Unix timestamp in seconds since 1970‑01‑01T00:00:00Z.
Definition types.hpp:49
Main namespace for the Time Shield library.
Header file for time formatting utilities.
Helpers for converting supported regional time zones and UTC.