Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
Time Validation

A comprehensive set of functions for validating dates, times, leap years, and time zones. More...

Functions

template<class T = year_t>
constexpr const bool time_shield::is_leap_year_date (T year) noexcept
 Checks if the given year is a leap year.
 
template<class T = year_t>
constexpr const bool time_shield::check_leap_year (T year) noexcept
 Alias for is_leap_year_date function.
 
template<class T = year_t>
constexpr const bool time_shield::leap_year (T year) noexcept
 Alias for is_leap_year_date function.
 
TIME_SHIELD_CONSTEXPR bool time_shield::is_leap_year_ts (ts_t ts)
 Checks if the given year is a leap year.
 
TIME_SHIELD_CONSTEXPR bool time_shield::leap_year_ts (ts_t ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR bool time_shield::check_leap_year_ts (ts_t ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR bool time_shield::is_leap_year (ts_t ts)
 Alias for is_leap_year_ts function.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone (T hour, T min) noexcept
 Check if the time zone is valid.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_tz (T hour, T min)
 Alias for is_valid_time_zone function.
 
template<class T1 = int, class T2 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time (T1 hour, T1 min, T1 sec, T2 ms=0) noexcept
 Checks the correctness of the specified time.
 
template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date (T1 year, T2 month, T2 day) noexcept
 Checks the correctness of the specified date.
 
template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date_time (T1 year, T2 month, T2 day, T2 hour=0, T2 min=0, T2 sec=0, T3 ms=0) noexcept
 Checks the correctness of a date and time.
 
TIME_SHIELD_CONSTEXPR bool time_shield::is_day_off (ts_t ts) noexcept
 Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).
 
TIME_SHIELD_CONSTEXPR bool time_shield::is_weekend (ts_t ts) noexcept
 Alias for is_day_off function.
 
template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_day_off_unix_day (T unix_day) noexcept
 Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.
 
template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_weekend_unix_day (T unix_day) noexcept
 Alias for is_day_off_unix_day function.
 
bool time_shield::is_leap_year_date (const long year)
 Checks if the given year is a leap year.
 
bool time_shield::check_leap_year (const long year)
 Alias for is_leap_year_date.
 
bool time_shield::leap_year (const long year)
 Alias for is_leap_year_date.
 
bool time_shield::is_leap_year_ts (const long ts)
 Checks if the year of the given timestamp is a leap year.
 
bool time_shield::leap_year_ts (const long ts)
 Alias for is_leap_year_ts.
 
bool time_shield::check_leap_year_ts (const long ts)
 Alias for is_leap_year_ts.
 
bool time_shield::is_leap_year (const long ts)
 Alias for is_leap_year_ts.
 
bool time_shield::is_valid_time_zone (const int hour, const int min)
 Check if the time zone components are valid.
 
bool time_shield::is_valid_tz (const int hour, const int min)
 Alias for is_valid_time_zone.
 
bool time_shield::is_valid_time_zone_offset (const TimeZoneStruct &time_zone)
 Check if the time zone structure is valid.
 
bool time_shield::is_valid_time_zone (const TimeZoneStruct &time_zone)
 Alias for is_valid_time_zone_offset.
 
bool time_shield::is_valid_tz (const TimeZoneStruct &time_zone)
 Alias for is_valid_time_zone_offset.
 
bool time_shield::is_valid_time (const int hour, const int min, const int sec, const int ms=0)
 Checks the correctness of the specified time.
 
bool time_shield::is_valid_time (const TimeStruct &time)
 Checks the correctness of the specified time structure.
 
bool time_shield::is_valid_date (const long year, const int month, const int day)
 Checks the correctness of the specified date.
 
bool time_shield::is_valid_date (const DateStruct &date)
 Checks the correctness of the specified date structure.
 
bool time_shield::is_valid_date_time (const long year, const int month, const int day, const int hour=0, const int min=0, const int sec=0, const int ms=0)
 Checks the correctness of date and time components.
 
bool time_shield::is_valid_date_time (const DateTimeStruct &date_time)
 Checks the correctness of the date-time structure.
 
bool time_shield::is_day_off (const long ts)
 Check if a timestamp corresponds to a weekend day.
 
bool time_shield::is_weekend (const long ts)
 Alias for is_day_off.
 
bool time_shield::is_day_off_unix_day (const long unix_day)
 Check if a Unix day corresponds to a weekend day.
 
bool time_shield::is_weekend_unix_day (const long unix_day)
 Alias for is_day_off_unix_day.
 

Detailed Description

A comprehensive set of functions for validating dates, times, leap years, and time zones.

Functions for validating dates, times and time zones.

This module provides functionalities to validate the correctness of date-time values, leap years, and time zone offsets. It also includes utilities for determining weekends and ensuring the validity of timestamp-based calculations.

Key Features:

Usage Examples:

Function Documentation

◆ check_leap_year() [1/2]

bool time_shield::check_leap_year ( const long year)

Alias for is_leap_year_date.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 43 of file validation.mqh.

◆ check_leap_year() [2/2]

template<class T = year_t>
const bool time_shield::check_leap_year ( T year)
constexprnoexcept

Alias for is_leap_year_date function.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 61 of file validation.hpp.

◆ check_leap_year_ts() [1/2]

bool time_shield::check_leap_year_ts ( const long ts)

Alias for is_leap_year_ts.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 87 of file validation.mqh.

◆ check_leap_year_ts() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::check_leap_year_ts ( ts_t ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 120 of file validation.hpp.

◆ is_day_off() [1/2]

bool time_shield::is_day_off ( const long ts)

Check if a timestamp corresponds to a weekend day.

Parameters
tsTimestamp to check.
Returns
true if the day is a weekend day, false otherwise.

Definition at line 226 of file validation.mqh.

◆ is_day_off() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::is_day_off ( ts_t ts)
inlinenoexcept

Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).

This function checks if the given timestamp falls on a weekend day, which is either Saturday or Sunday.

Parameters
tsTimestamp to check (default: current timestamp).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 313 of file validation.hpp.

◆ is_day_off_unix_day() [1/2]

bool time_shield::is_day_off_unix_day ( const long unix_day)

Check if a Unix day corresponds to a weekend day.

Parameters
unix_dayNumber of days since Unix epoch.
Returns
true if the day is a weekend day, false otherwise.

Definition at line 238 of file validation.mqh.

◆ is_day_off_unix_day() [2/2]

template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_day_off_unix_day ( T unix_day)
inlinenoexcept

Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.

Parameters
unix_dayDay to check (number of days since Unix epoch).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 332 of file validation.hpp.

◆ is_leap_year() [1/2]

bool time_shield::is_leap_year ( const long ts)

Alias for is_leap_year_ts.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 91 of file validation.mqh.

◆ is_leap_year() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::is_leap_year ( ts_t ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 126 of file validation.hpp.

◆ is_leap_year_date() [1/2]

bool time_shield::is_leap_year_date ( const long year)

Checks if the given year is a leap year.

Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 37 of file validation.mqh.

◆ is_leap_year_date() [2/2]

template<class T = year_t>
const bool time_shield::is_leap_year_date ( T year)
constexprnoexcept

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 54 of file validation.hpp.

◆ is_leap_year_ts() [1/2]

bool time_shield::is_leap_year_ts ( const long ts)

Checks if the year of the given timestamp is a leap year.

Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
true if the year is a leap year, false otherwise.

Definition at line 54 of file validation.mqh.

◆ is_leap_year_ts() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::is_leap_year_ts ( ts_t ts)

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 82 of file validation.hpp.

◆ is_valid_date() [1/3]

bool time_shield::is_valid_date ( const DateStruct & date)

Checks the correctness of the specified date structure.

Parameters
dateDate structure.
Returns
true if the date is valid, false otherwise.

Definition at line 186 of file validation.mqh.

◆ is_valid_date() [2/3]

bool time_shield::is_valid_date ( const long year,
const int month,
const int day )

Checks the correctness of the specified date.

Parameters
yearYear component.
monthMonth component.
dayDay component.
Returns
true if the date is valid, false otherwise.

Definition at line 158 of file validation.mqh.

◆ is_valid_date() [3/3]

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date ( T1 year,
T2 month,
T2 day )
inlinenoexcept

Checks the correctness of the specified date.

Template Parameters
T1The type of the year or day value (default is year_t).
T2The type of the month and day values (default is int).
Parameters
yearYear or day.
monthMonth.
dayDay or year.
Returns
true if the date is valid, false otherwise.

Definition at line 228 of file validation.hpp.

◆ is_valid_date_time() [1/3]

bool time_shield::is_valid_date_time ( const DateTimeStruct & date_time)

Checks the correctness of the date-time structure.

Parameters
date_timeDate-time structure.
Returns
true if the date and time are valid, false otherwise.

Definition at line 215 of file validation.mqh.

◆ is_valid_date_time() [2/3]

bool time_shield::is_valid_date_time ( const long year,
const int month,
const int day,
const int hour = 0,
const int min = 0,
const int sec = 0,
const int ms = 0 )

Checks the correctness of date and time components.

Parameters
yearYear component.
monthMonth component.
dayDay component.
hourHour component (default is 0).
minMinute component (default is 0).
secSecond component (default is 0).
msMillisecond component (default is 0).
Returns
true if the date and time are valid, false otherwise.

Definition at line 199 of file validation.mqh.

◆ is_valid_date_time() [3/3]

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_date_time ( T1 year,
T2 month,
T2 day,
T2 hour = 0,
T2 min = 0,
T2 sec = 0,
T3 ms = 0 )
inlinenoexcept

Checks the correctness of a date and time.

Template Parameters
T1The type of the year or day value (default is year_t).
T2The type of the month and day values (default is int).
T3The type of the millisecond value (default is int).
Parameters
yearYear or day.
monthMonth.
dayDay or year.
hourHour (default is 0).
minMinute (default is 0).
secSecond (default is 0).
msMillisecond (default is 0).
Returns
true if the date and time are valid, false otherwise.

Definition at line 279 of file validation.hpp.

◆ is_valid_time() [1/3]

bool time_shield::is_valid_time ( const int hour,
const int min,
const int sec,
const int ms = 0 )

Checks the correctness of the specified time.

Parameters
hourHour component.
minMinute component.
secSecond component.
msMillisecond component (default is 0).
Returns
true if the time is valid, false otherwise.

Definition at line 138 of file validation.mqh.

◆ is_valid_time() [2/3]

bool time_shield::is_valid_time ( const TimeStruct & time)

Checks the correctness of the specified time structure.

Parameters
timeTime structure.
Returns
true if the time is valid, false otherwise.

Definition at line 149 of file validation.mqh.

◆ is_valid_time() [3/3]

template<class T1 = int, class T2 = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time ( T1 hour,
T1 min,
T1 sec,
T2 ms = 0 )
inlinenoexcept

Checks the correctness of the specified time.

Template Parameters
T1The type of the hour, minute, and second values (default is int).
T2The type of the millisecond value (default is int).
Parameters
hourHour
minMinute
secSecond
msMillisecond (default is 0).
Returns
true if the time is valid, false otherwise.

Definition at line 197 of file validation.hpp.

◆ is_valid_time_zone() [1/3]

bool time_shield::is_valid_time_zone ( const int hour,
const int min )

Check if the time zone components are valid.

Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
true if the time zone is valid, false otherwise.

Definition at line 99 of file validation.mqh.

◆ is_valid_time_zone() [2/3]

bool time_shield::is_valid_time_zone ( const TimeZoneStruct & time_zone)

Alias for is_valid_time_zone_offset.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
time_zoneThe time zone structure containing hour and minute components.
Returns
True if the time zone is valid, false otherwise.

Definition at line 120 of file validation.mqh.

◆ is_valid_time_zone() [3/3]

template<class T = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_time_zone ( T hour,
T min )
inlinenoexcept

Check if the time zone is valid.

Template Parameters
TThe type of the time zone components (default is int).
Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
True if the time zone is valid, false otherwise.

Definition at line 138 of file validation.hpp.

◆ is_valid_time_zone_offset()

bool time_shield::is_valid_time_zone_offset ( const TimeZoneStruct & time_zone)

Check if the time zone structure is valid.

Parameters
time_zoneStructure containing hour and minute components.
Returns
true if the time zone is valid, false otherwise.

Definition at line 114 of file validation.mqh.

◆ is_valid_tz() [1/3]

bool time_shield::is_valid_tz ( const int hour,
const int min )

Alias for is_valid_time_zone.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone components (default is int).
Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
True if the time zone is valid, false otherwise.

Definition at line 107 of file validation.mqh.

◆ is_valid_tz() [2/3]

bool time_shield::is_valid_tz ( const TimeZoneStruct & time_zone)

Alias for is_valid_time_zone_offset.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone structure (default is TimeZoneStruct).
Parameters
time_zoneThe time zone structure containing hour and minute components.
Returns
True if the time zone is valid, false otherwise.

Definition at line 126 of file validation.mqh.

◆ is_valid_tz() [3/3]

template<class T = int>
TIME_SHIELD_CONSTEXPR bool time_shield::is_valid_tz ( T hour,
T min )
inline

Alias for is_valid_time_zone function.

Check if the time zone is valid.

Template Parameters
TThe type of the time zone components (default is int).
Parameters
hourThe hour component of the time zone.
minThe minute component of the time zone.
Returns
True if the time zone is valid, false otherwise.

Definition at line 149 of file validation.hpp.

◆ is_weekend() [1/2]

bool time_shield::is_weekend ( const long ts)

Alias for is_day_off.

Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).

This function checks if the given timestamp falls on a weekend day, which is either Saturday or Sunday.

Parameters
tsTimestamp to check (default: current timestamp).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 233 of file validation.mqh.

◆ is_weekend() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::is_weekend ( ts_t ts)
inlinenoexcept

Alias for is_day_off function.

Check if a given timestamp corresponds to a weekend day (Saturday or Sunday).

This function checks if the given timestamp falls on a weekend day, which is either Saturday or Sunday.

Parameters
tsTimestamp to check (default: current timestamp).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 320 of file validation.hpp.

◆ is_weekend_unix_day() [1/2]

bool time_shield::is_weekend_unix_day ( const long unix_day)

Alias for is_day_off_unix_day.

Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.

Parameters
unix_dayDay to check (number of days since Unix epoch).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 245 of file validation.mqh.

◆ is_weekend_unix_day() [2/2]

template<class T = uday_t>
TIME_SHIELD_CONSTEXPR bool time_shield::is_weekend_unix_day ( T unix_day)
inlinenoexcept

Alias for is_day_off_unix_day function.

Check if a given day (since Unix epoch) corresponds to a weekend day (Saturday or Sunday). This function checks if the given day (number of days since Unix epoch) falls on a weekend day, which is either Saturday or Sunday.

Parameters
unix_dayDay to check (number of days since Unix epoch).
Returns
true if the day is a weekend day, false otherwise.

Definition at line 340 of file validation.hpp.

◆ leap_year() [1/2]

bool time_shield::leap_year ( const long year)

Alias for is_leap_year_date.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 47 of file validation.mqh.

◆ leap_year() [2/2]

template<class T = year_t>
const bool time_shield::leap_year ( T year)
constexprnoexcept

Alias for is_leap_year_date function.

Checks if the given year is a leap year.

Template Parameters
TThe type of the year (default is year_t).
Parameters
yearYear to check.
Returns
true if the year is a leap year, false otherwise.

Definition at line 68 of file validation.hpp.

◆ leap_year_ts() [1/2]

bool time_shield::leap_year_ts ( const long ts)

Alias for is_leap_year_ts.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 83 of file validation.mqh.

◆ leap_year_ts() [2/2]

TIME_SHIELD_CONSTEXPR bool time_shield::leap_year_ts ( ts_t ts)

Alias for is_leap_year_ts function.

Checks if the given year is a leap year.

This function determines whether the year corresponding to the provided timestamp is a leap year.

Template Parameters
TThe type of the year parameter (default is year_t).
Parameters
tsTimestamp in seconds since the Unix epoch.
Returns
Returns true if the year is a leap year.

Definition at line 114 of file validation.hpp.