7#ifndef __TIME_SHIELD_TIME_ZONE_STRUCT_MQH__
8#define __TIME_SHIELD_TIME_ZONE_STRUCT_MQH__
17#property copyright "Copyright 2025, NewYaroslav"
18#property link "https://github.com/NewYaroslav/time-shield-cpp"
25 struct TimeZoneStruct {
40 const bool is_positive =
true) {
41 TimeZoneStruct result;
44 result.is_positive = is_positive;
56 int abs_val = (int)MathAbs(offset);
59 bool is_positive = (offset >= 0);
67 TimeZoneStruct
to_tz(
const int offset) {
79 string result = tz.is_positive ?
"+" :
"-";
82 result += IntegerToString(tz.hour);
86 result += IntegerToString(tz.min);
94 string to_string(
const TimeZoneStruct &tz) {
102 string to_str(
const TimeZoneStruct &tz) {
114 int sign = tz.is_positive ? 1 : -1;
128 int to_offset(
const TimeZoneStruct &tz) {
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
constexpr int64_t SEC_PER_MIN
Seconds per minute.
const tz_t time_zone_struct_to_offset(const TimeZoneStruct &tz)
Converts a TimeZoneStruct to a single integer representation.
const tz_t tz_to_offset(const TimeZoneStruct &tz)
Alias for time_zone_struct_to_offset function.
const TimeZoneStruct to_tz(tz_t offset)
Alias for to_time_zone_struct function.
const tz_t to_offset(const TimeZoneStruct &tz)
Alias for time_zone_struct_to_offset function.
const TimeZoneStruct to_time_zone_struct(tz_t offset)
Converts an integer to a TimeZoneStruct.
const std::string & to_str(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
const TimeZoneStruct create_time_zone_struct(int hour, int min, bool is_positive=true)
Creates a TimeZoneStruct instance.
Main namespace for the Time Shield library.
int hour
Hour component of time (0-23)
int min
Minute component of time (0-59)
bool is_positive
True if the time zone offset is positive, false if negative.