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.
 
Weekday weekday () const
 Local weekday.
 
int iso_weekday () const
 Local ISO weekday number (1..7).
 
IsoWeekDateStruct iso_week_date () const
 Local 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 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 ()
 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 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 36 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 39 of file DateTime.hpp.

◆ DateTime() [2/4]

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

Definition at line 560 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 448 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 443 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 438 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 428 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 433 of file DateTime.hpp.

◆ date()

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

Local date components.

Definition at line 333 of file DateTime.hpp.

◆ day()

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

Local day component.

Definition at line 308 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 453 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 458 of file DateTime.hpp.

◆ end_of_day()

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

End of local day.

Definition at line 480 of file DateTime.hpp.

◆ end_of_month()

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

End of local month.

Definition at line 501 of file DateTime.hpp.

◆ end_of_year()

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

End of local year.

Definition at line 523 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 265 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 253 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 259 of file DateTime.hpp.

◆ from_components()

static 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 67 of file DateTime.hpp.

◆ from_date_time_struct()

static 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()

static 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 153 of file DateTime.hpp.

◆ from_unix_ms() [1/2]

static 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]

static 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 47 of file DateTime.hpp.

◆ from_unix_s()

static 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 55 of file DateTime.hpp.

◆ hour()

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

Local hour component.

Definition at line 313 of file DateTime.hpp.

◆ is_weekend()

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

Check if local date is a weekend.

Definition at line 388 of file DateTime.hpp.

◆ is_workday()

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

Check if local date is a workday.

Definition at line 383 of file DateTime.hpp.

◆ iso_week_date()

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

Local ISO week date.

Definition at line 377 of file DateTime.hpp.

◆ iso_weekday()

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

Local ISO weekday number (1..7).

Definition at line 371 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 568 of file DateTime.hpp.

◆ millisecond()

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

Local millisecond component.

Definition at line 328 of file DateTime.hpp.

◆ minute()

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

Local minute component.

Definition at line 318 of file DateTime.hpp.

◆ month()

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

Local month component.

Definition at line 303 of file DateTime.hpp.

◆ now_utc() [1/2]

static 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]

static 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 set to now.

Definition at line 62 of file DateTime.hpp.

◆ offset_to_ms() [1/2]

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

Definition at line 134 of file DateTime.mqh.

◆ offset_to_ms() [2/2]

static constexpr ts_ms_t time_shield::DateTime::offset_to_ms ( tz_t offset)
inlinestaticconstexprprivatenoexcept

Definition at line 564 of file DateTime.hpp.

◆ operator!=()

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

Compare inequality by UTC instant.

Definition at line 398 of file DateTime.hpp.

◆ operator<()

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

Less-than comparison by UTC instant.

Definition at line 403 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 408 of file DateTime.hpp.

◆ operator==()

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

Compare equality by UTC instant.

Definition at line 393 of file DateTime.hpp.

◆ operator>()

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

Greater-than comparison by UTC instant.

Definition at line 413 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 418 of file DateTime.hpp.

◆ parse_iso8601() [1/3]

static 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 212 of file DateTime.hpp.

◆ parse_iso8601() [2/3]

static 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 196 of file DateTime.hpp.

◆ parse_iso8601() [3/3]

static 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 204 of file DateTime.hpp.

◆ parse_iso8601_buffer()

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

Definition at line 552 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 423 of file DateTime.hpp.

◆ second()

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

Local second component.

Definition at line 323 of file DateTime.hpp.

◆ start_of_day()

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

Start of local day.

Definition at line 473 of file DateTime.hpp.

◆ start_of_month()

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

Start of local month.

Definition at line 494 of file DateTime.hpp.

◆ start_of_year()

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

Start of local year.

Definition at line 516 of file DateTime.hpp.

◆ time_of_day()

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

Local time-of-day components.

Definition at line 339 of file DateTime.hpp.

◆ time_zone()

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

Get timezone structure from offset.

Definition at line 293 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 143 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 148 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 243 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 248 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 273 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 468 of file DateTime.hpp.

◆ try_from_components() [1/2]

static 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]

static 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 92 of file DateTime.hpp.

◆ try_from_date_time_struct() [1/2]

static 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]

static 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]

static 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 186 of file DateTime.hpp.

◆ try_parse_iso8601() [2/4]

static 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 168 of file DateTime.hpp.

◆ try_parse_iso8601() [3/4]

static 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]

static 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 177 of file DateTime.hpp.

◆ try_parse_iso8601_buffer()

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

Definition at line 537 of file DateTime.hpp.

◆ try_parse_iso_week_date() [1/3]

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

Try to parse ISO week-date C-string.

Definition at line 235 of file DateTime.hpp.

◆ try_parse_iso_week_date() [2/3]

static 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.

Definition at line 223 of file DateTime.hpp.

◆ try_parse_iso_week_date() [3/3]

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

Try to parse ISO week-date string_view.

Definition at line 229 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 278 of file DateTime.hpp.

◆ unix_s()

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

Access UTC seconds.

Definition at line 283 of file DateTime.hpp.

◆ utc_date()

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

UTC date components.

Definition at line 349 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 288 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 355 of file DateTime.hpp.

◆ weekday()

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

Local weekday.

Definition at line 365 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 463 of file DateTime.hpp.

◆ year()

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

Local year component.

Definition at line 298 of file DateTime.hpp.

Member Data Documentation

◆ m_offset [1/2]

tz_t time_shield::DateTime::m_offset
private

Definition at line 573 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 572 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: