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
6
7#include <iostream>
8
9#if defined(_WIN32)
12
13int main() {
14 using namespace time_shield;
15
16 // Create a timestamp for 2024-06-21 12:00:00 CET
17 ts_t cet_ts = to_ts(2024, Month::JUN, 21, 12, 0, 0);
18 ts_t gmt_from_cet = cet_to_gmt(cet_ts);
19
20 // Create a timestamp for 2024-06-21 12:00:00 EET
21 ts_t eet_ts = to_ts(2024, Month::JUN, 21, 12, 0, 0);
22 ts_t gmt_from_eet = eet_to_gmt(eet_ts);
23
24 std::cout << "CET time: " << to_iso8601(cet_ts) << '\n';
25 std::cout << "GMT from CET: " << to_iso8601(gmt_from_cet) << '\n';
26
27 std::cout << "EET time: " << to_iso8601(eet_ts) << '\n';
28 std::cout << "GMT from EET: " << to_iso8601(gmt_from_eet) << '\n';
29
30 std::cout << "Press Enter to exit..." << std::endl;
31 std::cin.get();
32 return 0;
33}
34#else
35int main() {
36 std::cout << "time_zone_conversions.hpp requires Windows." << std::endl;
37 return 0;
38}
39#endif
const ts_t eet_to_gmt(ts_t eet)
Convert Eastern European Time to Greenwich Mean Time.
const ts_t cet_to_gmt(ts_t cet)
Convert Central European Time to Greenwich Mean Time.
TIME_SHIELD_CONSTEXPR ts_t to_ts(year_t year, int month, int day)
Alias for to_timestamp.
const std::string to_iso8601(T ts)
Converts a timestamp to an ISO8601 string.
int64_t ts_t
Unix timestamp in seconds since 1970‑01‑01T00:00:00Z.
Definition types.hpp:45
Main namespace for the Time Shield library.
Header file for time formatting utilities.
Helpers for converting CET/EET timestamps to GMT.