3#ifndef _TIME_SHIELD_TIME_ZONE_STRUCT_HPP_INCLUDED
4#define _TIME_SHIELD_TIME_ZONE_STRUCT_HPP_INCLUDED
37 bool is_positive =
true) {
48 const int64_t off =
static_cast<int64_t
>(offset);
49 const int64_t abs_val = (off < 0) ? -off : off;
51 const int hour =
static_cast<int>(abs_val /
static_cast<int64_t
>(
SEC_PER_HOUR));
52 const int min =
static_cast<int>((abs_val %
static_cast<int64_t
>(
SEC_PER_HOUR)) /
74 return std::string(1, sign) + (tz.
hour < 10 ?
"0" :
"") + std::to_string(tz.
hour) +
":" + (tz.
min < 10 ?
"0" :
"") + std::to_string(tz.
min);
Configuration macros for the library.
Header file with time-related constants.
constexpr int64_t SEC_PER_HOUR
Seconds per hour.
constexpr int64_t SEC_PER_MIN
Seconds per minute.
const std::string & to_str(Weekday value, FormatType format=UPPERCASE_NAME)
Converts a Weekday enum value to a string.
TIME_SHIELD_CONSTEXPR tz_t to_offset(const TimeZoneStruct &tz) noexcept
Alias for time_zone_struct_to_offset.
TIME_SHIELD_CONSTEXPR tz_t time_zone_struct_to_offset(const TimeZoneStruct &tz) noexcept
Convert a TimeZoneStruct to a numeric UTC offset (seconds).
TimeZoneStruct to_tz(tz_t offset)
Alias for to_time_zone_struct function.
TIME_SHIELD_CONSTEXPR tz_t tz_to_offset(const TimeZoneStruct &tz) noexcept
Alias for time_zone_struct_to_offset.
TimeZoneStruct to_time_zone_struct(tz_t offset)
Converts an integer to a TimeZoneStruct.
TimeZoneStruct create_time_zone_struct(int hour, int min, bool is_positive=true)
Creates a TimeZoneStruct instance.
int32_t tz_t
Time zone offset in minutes from UTC (e.g., +180 = UTC+3).
Main namespace for the Time Shield library.
Structure to represent time zone information.
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.
Type definitions for time-related units and formats.