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 const bool time_shield::is_leap_year_ts (ts_t ts)
 Checks if the given year is a leap year.
 
TIME_SHIELD_CONSTEXPR const bool time_shield::leap_year_ts (ts_t ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR const bool time_shield::check_leap_year_ts (ts_t ts)
 Alias for is_leap_year_ts function.
 
TIME_SHIELD_CONSTEXPR const bool time_shield::is_leap_year (ts_t ts)
 Alias for is_leap_year_ts function.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR const 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 const 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 const 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 const 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 const 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 const 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.
 

Detailed Description

A comprehensive set of functions for validating dates, times, leap years, 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()

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 60 of file validation.hpp.

◆ check_leap_year_ts()

TIME_SHIELD_CONSTEXPR const 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 119 of file validation.hpp.

◆ is_day_off()

TIME_SHIELD_CONSTEXPR const 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 312 of file validation.hpp.

◆ is_day_off_unix_day()

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 331 of file validation.hpp.

◆ is_leap_year()

TIME_SHIELD_CONSTEXPR const 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 125 of file validation.hpp.

◆ is_leap_year_date()

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 53 of file validation.hpp.

◆ is_leap_year_ts()

TIME_SHIELD_CONSTEXPR const 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 81 of file validation.hpp.

◆ is_valid_date()

template<class T1 = year_t, class T2 = int>
TIME_SHIELD_CONSTEXPR const 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 227 of file validation.hpp.

◆ is_valid_date_time()

template<class T1 = year_t, class T2 = int, class T3 = int>
TIME_SHIELD_CONSTEXPR const 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 278 of file validation.hpp.

◆ is_valid_time()

template<class T1 = int, class T2 = int>
TIME_SHIELD_CONSTEXPR const 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 196 of file validation.hpp.

◆ is_valid_time_zone()

template<class T = int>
TIME_SHIELD_CONSTEXPR const 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 137 of file validation.hpp.

◆ is_valid_tz()

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 148 of file validation.hpp.

◆ is_weekend()

TIME_SHIELD_CONSTEXPR const 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 319 of file validation.hpp.

◆ is_weekend_unix_day()

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 339 of file validation.hpp.

◆ leap_year()

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

◆ leap_year_ts()

TIME_SHIELD_CONSTEXPR const 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 113 of file validation.hpp.