Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_shield::DateTime Class Reference

Represents a moment in time with optional fixed UTC offset. More...

#include <DateTime.hpp>

Public Member Functions

 DateTime () noexcept
 Default constructor sets epoch with zero offset.
DateTimeStruct to_date_time_struct_local () const
 Convert to date-time structure using stored offset.
DateTimeStruct to_date_time_struct_utc () const
 Convert to UTC date-time structure.
std::string to_iso8601 () const
 Format to ISO8601 string with stored offset.
std::string to_iso8601_utc () const
 Format to ISO8601 string in UTC.
std::string format (const std::string &fmt) const
 Format using custom pattern.
std::string format (std::string_view fmt) const
 Format using custom string_view pattern.
std::string format (const char *fmt) const
 Format using C-string pattern.
std::string to_mql5_date_time () const
 Format to MQL5 date-time string.
ts_ms_t unix_ms () const noexcept
 Access UTC milliseconds.
ts_t unix_s () const noexcept
 Access UTC seconds.
tz_t utc_offset () const noexcept
 Access stored UTC offset.
TimeZoneStruct time_zone () const
 Get timezone structure from offset.
year_t year () const
 Local year component.
int month () const
 Local month component.
int day () const
 Local day component.
int hour () const
 Local hour component.
int minute () const
 Local minute component.
int second () const
 Local second component.
int millisecond () const
 Local millisecond component.
DateStruct date () const
 Local date components.
TimeStruct time_of_day () const
 Local time-of-day components.
DateStruct utc_date () const
 UTC date components.
TimeStruct utc_time_of_day () const
 UTC time-of-day components.
year_t utc_year () const
 UTC year component.
int utc_month () const
 UTC month component.
int utc_day () const
 UTC day component.
int utc_hour () const
 UTC hour component.
int utc_minute () const
 UTC minute component.
int utc_second () const
 UTC second component.
int utc_millisecond () const
 UTC millisecond component.
Weekday weekday () const
 Local weekday.
int iso_weekday () const
 Local ISO weekday number (1..7).
IsoWeekDateStruct iso_week_date () const
 Local ISO week date.
Weekday utc_weekday () const
 UTC weekday.
int utc_iso_weekday () const
 UTC ISO weekday number (1..7).
IsoWeekDateStruct utc_iso_week_date () const
 UTC ISO week date.
bool is_workday () const noexcept
 Check if local date is a workday.
bool is_weekend () const noexcept
 Check if local date is a weekend.
bool utc_is_workday () const noexcept
 Check if UTC date is a workday.
bool utc_is_weekend () const noexcept
 Check if UTC date is a weekend.
bool operator== (const DateTime &other) const noexcept
 Compare equality by UTC instant.
bool operator!= (const DateTime &other) const noexcept
 Compare inequality by UTC instant.
bool operator< (const DateTime &other) const noexcept
 Less-than comparison by UTC instant.
bool operator<= (const DateTime &other) const noexcept
 Less-than-or-equal comparison by UTC instant.
bool operator> (const DateTime &other) const noexcept
 Greater-than comparison by UTC instant.
bool operator>= (const DateTime &other) const noexcept
 Greater-than-or-equal comparison by UTC instant.
bool same_local (const DateTime &other) const noexcept
 Check if local representations match including offset.
DateTime add_ms (int64_t delta_ms) const noexcept
 Add milliseconds to UTC instant.
DateTime add_seconds (int64_t seconds) const noexcept
 Add seconds to UTC instant.
DateTime add_minutes (int64_t minutes) const noexcept
 Add minutes to UTC instant.
DateTime add_hours (int64_t hours) const noexcept
 Add hours to UTC instant.
DateTime add_days (int64_t days) const noexcept
 Add days to UTC instant.
int64_t diff_ms (const DateTime &other) const noexcept
 Difference in milliseconds to another DateTime.
double diff_seconds (const DateTime &other) const noexcept
 Difference in seconds to another DateTime.
DateTime with_offset (tz_t new_offset) const noexcept
 Return copy with new offset preserving instant.
DateTime to_utc () const noexcept
 Return copy with zero offset.
DateTime start_of_day () const
 Start of local day.
DateTime end_of_day () const
 End of local day.
DateTime start_of_month () const
 Start of local month.
DateTime end_of_month () const
 End of local month.
DateTime start_of_year () const
 Start of local year.
DateTime end_of_year () const
 End of local year.
DateTime start_of_utc_day () const
 Start of UTC day.
DateTime end_of_utc_day () const
 End of UTC day.
DateTime start_of_utc_month () const
 Start of UTC month.
DateTime end_of_utc_month () const
 End of UTC month.
DateTime start_of_utc_year () const
 Start of UTC year.
DateTime end_of_utc_year () const
 End of UTC year.
 DateTime ()
 Default constructor initializes epoch with zero offset.
string to_iso8601 () const
 Format to ISO8601 string with stored offset.
long unix_ms () const
 Access UTC milliseconds.
int utc_offset () const
 Access stored UTC offset.
DateTime with_offset (const int new_offset) const
 Return copy with new offset preserving instant.
DateTime to_utc () const
 Return copy with zero offset.

Static Public Member Functions

static DateTime from_unix_ms (ts_ms_t utc_ms, tz_t offset=0) noexcept
 Create instance from UTC milliseconds.
static DateTime from_unix_s (ts_t utc_s, tz_t offset=0) noexcept
 Create instance from UTC seconds.
static DateTime now_utc (tz_t offset=0) noexcept
 Construct instance for current UTC time.
static DateTime from_components (year_t year, int month, int day, int hour=0, int min=0, int sec=0, int ms=0, tz_t offset=0)
 Build from calendar components interpreted in provided offset.
static bool try_from_components (year_t year, int month, int day, int hour, int min, int sec, int ms, tz_t offset, DateTime &out) noexcept
 Try to build from calendar components interpreted in provided offset.
static DateTime from_date_time_struct (const DateTimeStruct &local_dt, tz_t offset=0)
 Build from DateTimeStruct interpreted in provided offset.
static bool try_from_date_time_struct (const DateTimeStruct &local_dt, tz_t offset, DateTime &out) noexcept
 Try to build from DateTimeStruct interpreted in provided offset.
static DateTime from_iso_week_date (const IsoWeekDateStruct &iso, int hour=0, int min=0, int sec=0, int ms=0, tz_t offset=0)
 Build instance from ISO week date interpreted in provided offset.
static bool try_parse_iso8601 (const std::string &str, DateTime &out) noexcept
 Try to parse ISO8601 string to DateTime.
static bool try_parse_iso8601 (std::string_view str, DateTime &out) noexcept
 Try to parse ISO8601 string_view to DateTime.
static bool try_parse_iso8601 (const char *str, DateTime &out) noexcept
 Try to parse ISO8601 C-string to DateTime.
static DateTime parse_iso8601 (const std::string &str)
 Parse ISO8601 string, throws on failure.
static DateTime parse_iso8601 (std::string_view str)
 Parse ISO8601 string_view, throws on failure.
static DateTime parse_iso8601 (const char *str)
 Parse ISO8601 C-string, throws on failure.
static bool try_parse_iso_week_date (const std::string &str, IsoWeekDateStruct &iso) noexcept
 Try to parse ISO week-date string.
static bool try_parse_iso_week_date (std::string_view str, IsoWeekDateStruct &iso) noexcept
 Try to parse ISO week-date string_view.
static bool try_parse_iso_week_date (const char *str, IsoWeekDateStruct &iso) noexcept
 Try to parse ISO week-date C-string.
static DateTime from_unix_ms (const long utc_ms, const int offset=0)
 Create instance from UTC milliseconds.
static DateTime now_utc (const int offset=0)
 Construct instance for current UTC time.
static bool try_from_components (const long year, const int month, const int day, const int hour, const int min, const int sec, const int ms, const int offset, DateTime &out)
 Try to build from calendar components interpreted in provided offset.
static bool try_from_date_time_struct (const DateTimeStruct &local_dt, const int offset, DateTime &out)
 Try to build from DateTimeStruct interpreted in provided offset.
static bool try_parse_iso8601 (const string str, DateTime &out)
 Try to parse ISO8601 string to DateTime.

Private Member Functions

 DateTime (ts_ms_t utc_ms, tz_t offset) noexcept
ts_ms_t local_ms () const noexcept
 DateTime (const long utc_ms, const int offset)
long local_ms () const

Static Private Member Functions

static bool try_parse_iso8601_buffer (const char *data, std::size_t size, DateTime &out) noexcept
static DateTime parse_iso8601_buffer (const char *data, std::size_t size)
static TIME_SHIELD_CONSTEXPR ts_ms_t offset_to_ms (tz_t offset) noexcept
static long offset_to_ms (const int offset)

Private Attributes

ts_ms_t m_utc_ms
tz_t m_offset
long m_utc_ms
int m_offset

Detailed Description

Represents a moment in time with optional fixed UTC offset.

Represents a UTC timestamp with an optional fixed offset.

Equality and ordering compare the UTC instant only and ignore the stored offset.

Definition at line 37 of file DateTime.hpp.

Constructor & Destructor Documentation

◆ DateTime() [1/4]

time_shield::DateTime::DateTime ( )
inlinenoexcept

Default constructor sets epoch with zero offset.

Definition at line 40 of file DateTime.hpp.

◆ DateTime() [2/4]

time_shield::DateTime::DateTime ( ts_ms_t utc_ms,
tz_t offset )
inlineprivatenoexcept

Definition at line 696 of file DateTime.hpp.

◆ DateTime() [3/4]

time_shield::DateTime::DateTime ( )
inline

Default constructor initializes epoch with zero offset.

Definition at line 30 of file DateTime.mqh.

◆ DateTime() [4/4]

time_shield::DateTime::DateTime ( const long utc_ms,
const int offset )
inlineprivate

Definition at line 132 of file DateTime.mqh.

Member Function Documentation

◆ add_days()

DateTime time_shield::DateTime::add_days ( int64_t days) const
inlinenoexcept

Add days to UTC instant.

Definition at line 517 of file DateTime.hpp.

◆ add_hours()

DateTime time_shield::DateTime::add_hours ( int64_t hours) const
inlinenoexcept

Add hours to UTC instant.

Definition at line 512 of file DateTime.hpp.

◆ add_minutes()

DateTime time_shield::DateTime::add_minutes ( int64_t minutes) const
inlinenoexcept

Add minutes to UTC instant.

Definition at line 507 of file DateTime.hpp.

◆ add_ms()

DateTime time_shield::DateTime::add_ms ( int64_t delta_ms) const
inlinenoexcept

Add milliseconds to UTC instant.

Definition at line 497 of file DateTime.hpp.

◆ add_seconds()

DateTime time_shield::DateTime::add_seconds ( int64_t seconds) const
inlinenoexcept

Add seconds to UTC instant.

Definition at line 502 of file DateTime.hpp.

◆ date()

DateStruct time_shield::DateTime::date ( ) const
inline

Local date components.

Definition at line 338 of file DateTime.hpp.

◆ day()

int time_shield::DateTime::day ( ) const
inline

Local day component.

Definition at line 313 of file DateTime.hpp.

◆ diff_ms()

int64_t time_shield::DateTime::diff_ms ( const DateTime & other) const
inlinenoexcept

Difference in milliseconds to another DateTime.

Definition at line 522 of file DateTime.hpp.

◆ diff_seconds()

double time_shield::DateTime::diff_seconds ( const DateTime & other) const
inlinenoexcept

Difference in seconds to another DateTime.

Definition at line 527 of file DateTime.hpp.

◆ end_of_day()

DateTime time_shield::DateTime::end_of_day ( ) const
inline

End of local day.

Definition at line 549 of file DateTime.hpp.

◆ end_of_month()

DateTime time_shield::DateTime::end_of_month ( ) const
inline

End of local month.

Definition at line 570 of file DateTime.hpp.

◆ end_of_utc_day()

DateTime time_shield::DateTime::end_of_utc_day ( ) const
inline

End of UTC day.

Definition at line 612 of file DateTime.hpp.

◆ end_of_utc_month()

DateTime time_shield::DateTime::end_of_utc_month ( ) const
inline

End of UTC month.

Definition at line 633 of file DateTime.hpp.

◆ end_of_utc_year()

DateTime time_shield::DateTime::end_of_utc_year ( ) const
inline

End of UTC year.

Definition at line 655 of file DateTime.hpp.

◆ end_of_year()

DateTime time_shield::DateTime::end_of_year ( ) const
inline

End of local year.

Definition at line 592 of file DateTime.hpp.

◆ format() [1/3]

std::string time_shield::DateTime::format ( const char * fmt) const
inline

Format using C-string pattern.

Definition at line 270 of file DateTime.hpp.

◆ format() [2/3]

std::string time_shield::DateTime::format ( const std::string & fmt) const
inline

Format using custom pattern.

Definition at line 258 of file DateTime.hpp.

◆ format() [3/3]

std::string time_shield::DateTime::format ( std::string_view fmt) const
inline

Format using custom string_view pattern.

Definition at line 264 of file DateTime.hpp.

◆ from_components()

DateTime time_shield::DateTime::from_components ( year_t year,
int month,
int day,
int hour = 0,
int min = 0,
int sec = 0,
int ms = 0,
tz_t offset = 0 )
inlinestatic

Build from calendar components interpreted in provided offset.

Definition at line 68 of file DateTime.hpp.

◆ from_date_time_struct()

DateTime time_shield::DateTime::from_date_time_struct ( const DateTimeStruct & local_dt,
tz_t offset = 0 )
inlinestatic

Build from DateTimeStruct interpreted in provided offset.

Definition at line 115 of file DateTime.hpp.

◆ from_iso_week_date()

DateTime time_shield::DateTime::from_iso_week_date ( const IsoWeekDateStruct & iso,
int hour = 0,
int min = 0,
int sec = 0,
int ms = 0,
tz_t offset = 0 )
inlinestatic

Build instance from ISO week date interpreted in provided offset.

Definition at line 152 of file DateTime.hpp.

◆ from_unix_ms() [1/2]

DateTime time_shield::DateTime::from_unix_ms ( const long utc_ms,
const int offset = 0 )
inlinestatic

Create instance from UTC milliseconds.

Parameters
utc_msTimestamp in milliseconds since the Unix epoch (UTC).
offsetFixed UTC offset in seconds.
Returns
Constructed DateTime.

Definition at line 36 of file DateTime.mqh.

◆ from_unix_ms() [2/2]

DateTime time_shield::DateTime::from_unix_ms ( ts_ms_t utc_ms,
tz_t offset = 0 )
inlinestaticnoexcept

Create instance from UTC milliseconds.

Parameters
utc_msTimestamp in milliseconds since Unix epoch (UTC).
offsetFixed UTC offset in seconds.
Returns
Constructed DateTime.

Definition at line 48 of file DateTime.hpp.

◆ from_unix_s()

DateTime time_shield::DateTime::from_unix_s ( ts_t utc_s,
tz_t offset = 0 )
inlinestaticnoexcept

Create instance from UTC seconds.

Parameters
utc_sTimestamp in seconds since Unix epoch (UTC).
offsetFixed UTC offset in seconds.
Returns
Constructed DateTime.

Definition at line 56 of file DateTime.hpp.

◆ hour()

int time_shield::DateTime::hour ( ) const
inline

Local hour component.

Definition at line 318 of file DateTime.hpp.

◆ is_weekend()

bool time_shield::DateTime::is_weekend ( ) const
inlinenoexcept

Check if local date is a weekend.

Definition at line 446 of file DateTime.hpp.

◆ is_workday()

bool time_shield::DateTime::is_workday ( ) const
inlinenoexcept

Check if local date is a workday.

Definition at line 441 of file DateTime.hpp.

◆ iso_week_date()

IsoWeekDateStruct time_shield::DateTime::iso_week_date ( ) const
inline

Local ISO week date.

Definition at line 417 of file DateTime.hpp.

◆ iso_weekday()

int time_shield::DateTime::iso_weekday ( ) const
inline

Local ISO weekday number (1..7).

Definition at line 411 of file DateTime.hpp.

◆ local_ms() [1/2]

long time_shield::DateTime::local_ms ( ) const
inlineprivate

Definition at line 136 of file DateTime.mqh.

◆ local_ms() [2/2]

ts_ms_t time_shield::DateTime::local_ms ( ) const
inlineprivatenoexcept

Definition at line 704 of file DateTime.hpp.

◆ millisecond()

int time_shield::DateTime::millisecond ( ) const
inline

Local millisecond component.

Definition at line 333 of file DateTime.hpp.

◆ minute()

int time_shield::DateTime::minute ( ) const
inline

Local minute component.

Definition at line 323 of file DateTime.hpp.

◆ month()

int time_shield::DateTime::month ( ) const
inline

Local month component.

Definition at line 308 of file DateTime.hpp.

◆ now_utc() [1/2]

DateTime time_shield::DateTime::now_utc ( const int offset = 0)
inlinestatic

Construct instance for current UTC time.

Parameters
offsetFixed UTC offset in seconds.
Returns
DateTime set to now.

Definition at line 43 of file DateTime.mqh.

◆ now_utc() [2/2]

DateTime time_shield::DateTime::now_utc ( tz_t offset = 0)
inlinestaticnoexcept

Construct instance for current UTC time.

Parameters
offsetFixed UTC offset in seconds.
Returns
DateTime for the current UTC time.

Definition at line 63 of file DateTime.hpp.

◆ offset_to_ms() [1/2]

long time_shield::DateTime::offset_to_ms ( const int offset)
inlinestaticprivate

Definition at line 134 of file DateTime.mqh.

◆ offset_to_ms() [2/2]

TIME_SHIELD_CONSTEXPR ts_ms_t time_shield::DateTime::offset_to_ms ( tz_t offset)
inlinestaticprivatenoexcept

Definition at line 700 of file DateTime.hpp.

◆ operator!=()

bool time_shield::DateTime::operator!= ( const DateTime & other) const
inlinenoexcept

Compare inequality by UTC instant.

Definition at line 467 of file DateTime.hpp.

◆ operator<()

bool time_shield::DateTime::operator< ( const DateTime & other) const
inlinenoexcept

Less-than comparison by UTC instant.

Definition at line 472 of file DateTime.hpp.

◆ operator<=()

bool time_shield::DateTime::operator<= ( const DateTime & other) const
inlinenoexcept

Less-than-or-equal comparison by UTC instant.

Definition at line 477 of file DateTime.hpp.

◆ operator==()

bool time_shield::DateTime::operator== ( const DateTime & other) const
inlinenoexcept

Compare equality by UTC instant.

Definition at line 462 of file DateTime.hpp.

◆ operator>()

bool time_shield::DateTime::operator> ( const DateTime & other) const
inlinenoexcept

Greater-than comparison by UTC instant.

Definition at line 482 of file DateTime.hpp.

◆ operator>=()

bool time_shield::DateTime::operator>= ( const DateTime & other) const
inlinenoexcept

Greater-than-or-equal comparison by UTC instant.

Definition at line 487 of file DateTime.hpp.

◆ parse_iso8601() [1/3]

DateTime time_shield::DateTime::parse_iso8601 ( const char * str)
inlinestatic

Parse ISO8601 C-string, throws on failure.

Parameters
strNull-terminated ISO8601 string.
Returns
Parsed DateTime.

Definition at line 211 of file DateTime.hpp.

◆ parse_iso8601() [2/3]

DateTime time_shield::DateTime::parse_iso8601 ( const std::string & str)
inlinestatic

Parse ISO8601 string, throws on failure.

Parameters
strInput ISO8601 string.
Returns
Parsed DateTime.

Definition at line 195 of file DateTime.hpp.

◆ parse_iso8601() [3/3]

DateTime time_shield::DateTime::parse_iso8601 ( std::string_view str)
inlinestatic

Parse ISO8601 string_view, throws on failure.

Parameters
strInput ISO8601 view.
Returns
Parsed DateTime.

Definition at line 203 of file DateTime.hpp.

◆ parse_iso8601_buffer()

DateTime time_shield::DateTime::parse_iso8601_buffer ( const char * data,
std::size_t size )
inlinestaticprivate

Definition at line 688 of file DateTime.hpp.

◆ same_local()

bool time_shield::DateTime::same_local ( const DateTime & other) const
inlinenoexcept

Check if local representations match including offset.

Definition at line 492 of file DateTime.hpp.

◆ second()

int time_shield::DateTime::second ( ) const
inline

Local second component.

Definition at line 328 of file DateTime.hpp.

◆ start_of_day()

DateTime time_shield::DateTime::start_of_day ( ) const
inline

Start of local day.

Definition at line 542 of file DateTime.hpp.

◆ start_of_month()

DateTime time_shield::DateTime::start_of_month ( ) const
inline

Start of local month.

Definition at line 563 of file DateTime.hpp.

◆ start_of_utc_day()

DateTime time_shield::DateTime::start_of_utc_day ( ) const
inline

Start of UTC day.

Definition at line 606 of file DateTime.hpp.

◆ start_of_utc_month()

DateTime time_shield::DateTime::start_of_utc_month ( ) const
inline

Start of UTC month.

Definition at line 627 of file DateTime.hpp.

◆ start_of_utc_year()

DateTime time_shield::DateTime::start_of_utc_year ( ) const
inline

Start of UTC year.

Definition at line 649 of file DateTime.hpp.

◆ start_of_year()

DateTime time_shield::DateTime::start_of_year ( ) const
inline

Start of local year.

Definition at line 585 of file DateTime.hpp.

◆ time_of_day()

TimeStruct time_shield::DateTime::time_of_day ( ) const
inline

Local time-of-day components.

Definition at line 344 of file DateTime.hpp.

◆ time_zone()

TimeZoneStruct time_shield::DateTime::time_zone ( ) const
inline

Get timezone structure from offset.

Definition at line 298 of file DateTime.hpp.

◆ to_date_time_struct_local()

DateTimeStruct time_shield::DateTime::to_date_time_struct_local ( ) const
inline

Convert to date-time structure using stored offset.

Definition at line 142 of file DateTime.hpp.

◆ to_date_time_struct_utc()

DateTimeStruct time_shield::DateTime::to_date_time_struct_utc ( ) const
inline

Convert to UTC date-time structure.

Definition at line 147 of file DateTime.hpp.

◆ to_iso8601() [1/2]

std::string time_shield::DateTime::to_iso8601 ( ) const
inline

Format to ISO8601 string with stored offset.

Definition at line 248 of file DateTime.hpp.

◆ to_iso8601() [2/2]

string time_shield::DateTime::to_iso8601 ( ) const
inline

Format to ISO8601 string with stored offset.

Definition at line 117 of file DateTime.mqh.

◆ to_iso8601_utc()

std::string time_shield::DateTime::to_iso8601_utc ( ) const
inline

Format to ISO8601 string in UTC.

Definition at line 253 of file DateTime.hpp.

◆ to_mql5_date_time()

std::string time_shield::DateTime::to_mql5_date_time ( ) const
inline

Format to MQL5 date-time string.

Definition at line 278 of file DateTime.hpp.

◆ to_utc() [1/2]

DateTime time_shield::DateTime::to_utc ( ) const
inline

Return copy with zero offset.

Definition at line 129 of file DateTime.mqh.

◆ to_utc() [2/2]

DateTime time_shield::DateTime::to_utc ( ) const
inlinenoexcept

Return copy with zero offset.

Definition at line 537 of file DateTime.hpp.

◆ try_from_components() [1/2]

bool time_shield::DateTime::try_from_components ( const long year,
const int month,
const int day,
const int hour,
const int min,
const int sec,
const int ms,
const int offset,
DateTime & out )
inlinestatic

Try to build from calendar components interpreted in provided offset.

Parameters
yearYear component.
monthMonth component.
dayDay component.
hourHour component.
minMinute component.
secSecond component.
msMillisecond component.
offsetFixed UTC offset in seconds.
outOutput DateTime on success.
Returns
True when components form a valid date-time and offset.

Definition at line 58 of file DateTime.mqh.

◆ try_from_components() [2/2]

bool time_shield::DateTime::try_from_components ( year_t year,
int month,
int day,
int hour,
int min,
int sec,
int ms,
tz_t offset,
DateTime & out )
inlinestaticnoexcept

Try to build from calendar components interpreted in provided offset.

Parameters
yearYear component.
monthMonth component.
dayDay component.
hourHour component.
minMinute component.
secSecond component.
msMillisecond component.
offsetFixed UTC offset in seconds.
outOutput DateTime on success.
Returns
True when components form a valid date-time and offset.

Definition at line 93 of file DateTime.hpp.

◆ try_from_date_time_struct() [1/2]

bool time_shield::DateTime::try_from_date_time_struct ( const DateTimeStruct & local_dt,
const int offset,
DateTime & out )
inlinestatic

Try to build from DateTimeStruct interpreted in provided offset.

Parameters
local_dtLocal date-time structure.
offsetFixed UTC offset in seconds.
outOutput DateTime on success.
Returns
True when structure and offset are valid.

Definition at line 85 of file DateTime.mqh.

◆ try_from_date_time_struct() [2/2]

bool time_shield::DateTime::try_from_date_time_struct ( const DateTimeStruct & local_dt,
tz_t offset,
DateTime & out )
inlinestaticnoexcept

Try to build from DateTimeStruct interpreted in provided offset.

Parameters
local_dtLocal date-time structure.
offsetFixed UTC offset in seconds.
outOutput DateTime on success.
Returns
True when structure and offset are valid.

Definition at line 126 of file DateTime.hpp.

◆ try_parse_iso8601() [1/4]

bool time_shield::DateTime::try_parse_iso8601 ( const char * str,
DateTime & out )
inlinestaticnoexcept

Try to parse ISO8601 C-string to DateTime.

Parameters
strNull-terminated ISO8601 string.
outOutput DateTime when parsing succeeds.
Returns
True on success.

Definition at line 185 of file DateTime.hpp.

◆ try_parse_iso8601() [2/4]

bool time_shield::DateTime::try_parse_iso8601 ( const std::string & str,
DateTime & out )
inlinestaticnoexcept

Try to parse ISO8601 string to DateTime.

Parameters
strInput ISO8601 string.
outOutput DateTime when parsing succeeds.
Returns
True on success.

Definition at line 167 of file DateTime.hpp.

◆ try_parse_iso8601() [3/4]

bool time_shield::DateTime::try_parse_iso8601 ( const string str,
DateTime & out )
inlinestatic

Try to parse ISO8601 string to DateTime.

Parameters
strInput ISO8601 string.
outOutput DateTime when parsing succeeds.
Returns
True on success.

Definition at line 105 of file DateTime.mqh.

◆ try_parse_iso8601() [4/4]

bool time_shield::DateTime::try_parse_iso8601 ( std::string_view str,
DateTime & out )
inlinestaticnoexcept

Try to parse ISO8601 string_view to DateTime.

Parameters
strInput ISO8601 string_view.
outOutput DateTime when parsing succeeds.
Returns
True on success.

Definition at line 176 of file DateTime.hpp.

◆ try_parse_iso8601_buffer()

bool time_shield::DateTime::try_parse_iso8601_buffer ( const char * data,
std::size_t size,
DateTime & out )
inlinestaticprivatenoexcept

Definition at line 670 of file DateTime.hpp.

◆ try_parse_iso_week_date() [1/3]

bool time_shield::DateTime::try_parse_iso_week_date ( const char * str,
IsoWeekDateStruct & iso )
inlinestaticnoexcept

Try to parse ISO week-date C-string.

Parser accepts canonical and compatible mixed separator variants, uppercase or lowercase W, and Monday default when weekday is omitted.

Definition at line 240 of file DateTime.hpp.

◆ try_parse_iso_week_date() [2/3]

bool time_shield::DateTime::try_parse_iso_week_date ( const std::string & str,
IsoWeekDateStruct & iso )
inlinestaticnoexcept

Try to parse ISO week-date string.

Parameters
strInput ISO week-date string.
isoOutput ISO week-date structure.
Returns
True on success.

Parser accepts canonical and compatible mixed separator variants, uppercase or lowercase W, and Monday default when weekday is omitted.

Definition at line 224 of file DateTime.hpp.

◆ try_parse_iso_week_date() [3/3]

bool time_shield::DateTime::try_parse_iso_week_date ( std::string_view str,
IsoWeekDateStruct & iso )
inlinestaticnoexcept

Try to parse ISO week-date string_view.

Parser accepts canonical and compatible mixed separator variants, uppercase or lowercase W, and Monday default when weekday is omitted.

Definition at line 232 of file DateTime.hpp.

◆ unix_ms() [1/2]

long time_shield::DateTime::unix_ms ( ) const
inline

Access UTC milliseconds.

Definition at line 120 of file DateTime.mqh.

◆ unix_ms() [2/2]

ts_ms_t time_shield::DateTime::unix_ms ( ) const
inlinenoexcept

Access UTC milliseconds.

Definition at line 283 of file DateTime.hpp.

◆ unix_s()

ts_t time_shield::DateTime::unix_s ( ) const
inlinenoexcept

Access UTC seconds.

Definition at line 288 of file DateTime.hpp.

◆ utc_date()

DateStruct time_shield::DateTime::utc_date ( ) const
inline

UTC date components.

Definition at line 354 of file DateTime.hpp.

◆ utc_day()

int time_shield::DateTime::utc_day ( ) const
inline

UTC day component.

Definition at line 380 of file DateTime.hpp.

◆ utc_hour()

int time_shield::DateTime::utc_hour ( ) const
inline

UTC hour component.

Definition at line 385 of file DateTime.hpp.

◆ utc_is_weekend()

bool time_shield::DateTime::utc_is_weekend ( ) const
inlinenoexcept

Check if UTC date is a weekend.

Definition at line 457 of file DateTime.hpp.

◆ utc_is_workday()

bool time_shield::DateTime::utc_is_workday ( ) const
inlinenoexcept

Check if UTC date is a workday.

Definition at line 451 of file DateTime.hpp.

◆ utc_iso_week_date()

IsoWeekDateStruct time_shield::DateTime::utc_iso_week_date ( ) const
inline

UTC ISO week date.

Definition at line 435 of file DateTime.hpp.

◆ utc_iso_weekday()

int time_shield::DateTime::utc_iso_weekday ( ) const
inline

UTC ISO weekday number (1..7).

Definition at line 429 of file DateTime.hpp.

◆ utc_millisecond()

int time_shield::DateTime::utc_millisecond ( ) const
inline

UTC millisecond component.

Definition at line 400 of file DateTime.hpp.

◆ utc_minute()

int time_shield::DateTime::utc_minute ( ) const
inline

UTC minute component.

Definition at line 390 of file DateTime.hpp.

◆ utc_month()

int time_shield::DateTime::utc_month ( ) const
inline

UTC month component.

Definition at line 375 of file DateTime.hpp.

◆ utc_offset() [1/2]

int time_shield::DateTime::utc_offset ( ) const
inline

Access stored UTC offset.

Definition at line 123 of file DateTime.mqh.

◆ utc_offset() [2/2]

tz_t time_shield::DateTime::utc_offset ( ) const
inlinenoexcept

Access stored UTC offset.

Definition at line 293 of file DateTime.hpp.

◆ utc_second()

int time_shield::DateTime::utc_second ( ) const
inline

UTC second component.

Definition at line 395 of file DateTime.hpp.

◆ utc_time_of_day()

TimeStruct time_shield::DateTime::utc_time_of_day ( ) const
inline

UTC time-of-day components.

Definition at line 360 of file DateTime.hpp.

◆ utc_weekday()

Weekday time_shield::DateTime::utc_weekday ( ) const
inline

UTC weekday.

Definition at line 423 of file DateTime.hpp.

◆ utc_year()

year_t time_shield::DateTime::utc_year ( ) const
inline

UTC year component.

Definition at line 370 of file DateTime.hpp.

◆ weekday()

Weekday time_shield::DateTime::weekday ( ) const
inline

Local weekday.

Definition at line 405 of file DateTime.hpp.

◆ with_offset() [1/2]

DateTime time_shield::DateTime::with_offset ( const int new_offset) const
inline

Return copy with new offset preserving instant.

Definition at line 126 of file DateTime.mqh.

◆ with_offset() [2/2]

DateTime time_shield::DateTime::with_offset ( tz_t new_offset) const
inlinenoexcept

Return copy with new offset preserving instant.

Definition at line 532 of file DateTime.hpp.

◆ year()

year_t time_shield::DateTime::year ( ) const
inline

Local year component.

Definition at line 303 of file DateTime.hpp.

Member Data Documentation

◆ m_offset [1/2]

tz_t time_shield::DateTime::m_offset
private

Definition at line 709 of file DateTime.hpp.

◆ m_offset [2/2]

int time_shield::DateTime::m_offset
private

Definition at line 139 of file DateTime.mqh.

◆ m_utc_ms [1/2]

ts_ms_t time_shield::DateTime::m_utc_ms
private

Definition at line 708 of file DateTime.hpp.

◆ m_utc_ms [2/2]

long time_shield::DateTime::m_utc_ms
private

Definition at line 138 of file DateTime.mqh.


The documentation for this class was generated from the following files: