LocalTimeRK
Public Member Functions | Data Fields
LocalTimeRestrictedDate Class Reference

Day of week, date, or date exception restrictions. More...

#include <LocalTimeRK.h>

Inheritance diagram for LocalTimeRestrictedDate:
LocalTimeHMSRestricted LocalTimeRange

Public Member Functions

 LocalTimeRestrictedDate ()
 Create an empty restricted date object. It will return false for any date passed to isValid.
 
 LocalTimeRestrictedDate (uint8_t mask)
 Create a date restricted object restricted to days of the week. More...
 
 LocalTimeRestrictedDate (uint8_t mask, std::initializer_list< const char * > onlyOnDates, std::initializer_list< const char * > exceptDates)
 Construct an object with an initializer list of strings. More...
 
 LocalTimeRestrictedDate (uint8_t mask, std::initializer_list< LocalTimeYMD > onlyOnDates, std::initializer_list< LocalTimeYMD > exceptDates)
 Construct an object with an initializer list of LocalTimeYMD objects. More...
 
LocalTimeRestrictedDatewithOnAllDays ()
 Set the mask value to MASK_ALL. Does not change only on date or except on date lists. More...
 
LocalTimeRestrictedDatewithOnlyOnDays (LocalTimeDayOfWeek value)
 Restrict to days of the week. More...
 
LocalTimeRestrictedDatewithOnlyOnDays (uint8_t mask)
 Restrict to certain dates. More...
 
LocalTimeRestrictedDatewithOnlyOnDates (std::initializer_list< const char * > dates)
 Restrict to certain dates. More...
 
LocalTimeRestrictedDatewithOnlyOnDates (std::initializer_list< LocalTimeYMD > dates)
 Restrict to certain dates. More...
 
LocalTimeRestrictedDatewithExceptDates (std::initializer_list< const char * > dates)
 Dates that will always return false for isValid. More...
 
LocalTimeRestrictedDatewithExceptDates (std::initializer_list< LocalTimeYMD > dates)
 Dates that will always return false for isValid. More...
 
bool isEmpty () const
 Returns true if onlyOnDays mask is 0 and the onlyOnDates and exceptDates lists are empty. More...
 
void clear ()
 Clear all settings.
 
bool isValid (LocalTimeValue localTimeValue) const
 Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list. More...
 
bool isValid (LocalTimeYMD ymd) const
 Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list. More...
 
bool inOnlyOnDates (LocalTimeYMD ymd) const
 Returns true of a date is in the onlyOnDates list. More...
 
bool inExceptDates (LocalTimeYMD ymd) const
 Returns true of a date is in the exceptDates list. More...
 
LocalTimeYMD getExpirationDate () const
 Get the last date (YMD) that this restricted date could be valid. More...
 
void fromJson (JSONValue jsonObj)
 Fills in this object from JSON data. More...
 

Data Fields

LocalTimeDayOfWeek onlyOnDays
 Allow on that day of week if mask bit is set.
 
std::vector< LocalTimeYMDonlyOnDates
 Dates to allow.
 
std::vector< LocalTimeYMDexceptDates
 Dates to exclude.
 

Detailed Description

Day of week, date, or date exception restrictions.

This class can specify that something (typically a LocalTimeHMSRestricted or a LocalTimeRange) only applies on certain dates. This can be a mask of days of the week, optionally with specific dates that should be disallowed. Or you can schedule only on specific dates.

Constructor & Destructor Documentation

◆ LocalTimeRestrictedDate() [1/3]

LocalTimeRestrictedDate::LocalTimeRestrictedDate ( uint8_t  mask)
inline

Create a date restricted object restricted to days of the week.

Parameters
maskThe days of the week to enable. Pass LocalTimeDayOfWeek::MASK_ALL to allow on every day (no restrictions)

◆ LocalTimeRestrictedDate() [2/3]

LocalTimeRestrictedDate::LocalTimeRestrictedDate ( uint8_t  mask,
std::initializer_list< const char * >  onlyOnDates,
std::initializer_list< const char * >  exceptDates 
)
inline

Construct an object with an initializer list of strings.

Parameters
maskmask value, see LocalTimeDayOfWeek for values
onlyOnDatesInitializer list of strings of the form YYYY-MM-DD
exceptDatesInitializer list of strings of the form YYYY-MM-DD

◆ LocalTimeRestrictedDate() [3/3]

LocalTimeRestrictedDate::LocalTimeRestrictedDate ( uint8_t  mask,
std::initializer_list< LocalTimeYMD onlyOnDates,
std::initializer_list< LocalTimeYMD exceptDates 
)
inline

Construct an object with an initializer list of LocalTimeYMD objects.

Parameters
maskmask value, see LocalTimeDayOfWeek for values
onlyOnDatesInitializer list of LocalTimeYMD values
exceptDatesInitializer list of LocalTimeYMD values

Member Function Documentation

◆ fromJson()

void LocalTimeRestrictedDate::fromJson ( JSONValue  jsonObj)

Fills in this object from JSON data.

Parameters
jsonObj

Keys:

  • y (integer) mask value for onlyOnDays (optional)
  • a (array) Array of YYYY-MM-DD value strings to allow (optional)
  • x (array) Array of YYYY-MM-DD values to exclude (optional)

◆ getExpirationDate()

LocalTimeYMD LocalTimeRestrictedDate::getExpirationDate ( ) const

Get the last date (YMD) that this restricted date could be valid.

Returns
LocalTimeYMD

This will return the empty date for most cases. A valid value is returned if the only on date mode is used. In this case, there's as point in time where this range will never be true. This is used to optimize scheduling.

◆ inExceptDates()

bool LocalTimeRestrictedDate::inExceptDates ( LocalTimeYMD  ymd) const

Returns true of a date is in the exceptDates list.

Parameters
ymd
Returns
true
false

◆ inOnlyOnDates()

bool LocalTimeRestrictedDate::inOnlyOnDates ( LocalTimeYMD  ymd) const

Returns true of a date is in the onlyOnDates list.

Parameters
ymd
Returns
true
false

◆ isEmpty()

bool LocalTimeRestrictedDate::isEmpty ( ) const

Returns true if onlyOnDays mask is 0 and the onlyOnDates and exceptDates lists are empty.

Returns
true
false

◆ isValid() [1/2]

bool LocalTimeRestrictedDate::isValid ( LocalTimeValue  localTimeValue) const

Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.

Parameters
localTimeValueDate to check (local time)
Returns
true
false

◆ isValid() [2/2]

bool LocalTimeRestrictedDate::isValid ( LocalTimeYMD  ymd) const

Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.

Parameters
ymdDate to check (local time)
Returns
true
false

◆ withExceptDates() [1/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withExceptDates ( std::initializer_list< const char * >  dates)

Dates that will always return false for isValid.

Parameters
datesA {} list of strings of the form YYYY-MM-DD. No other date formats are allowed!
Returns
LocalTimeRestrictedDate&

If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.

◆ withExceptDates() [2/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withExceptDates ( std::initializer_list< LocalTimeYMD dates)

Dates that will always return false for isValid.

Parameters
datesA {} list of LocalTimeYMD objects
Returns
LocalTimeRestrictedDate&

If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.

◆ withOnAllDays()

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnAllDays ( )
inline

Set the mask value to MASK_ALL. Does not change only on date or except on date lists.

Returns
LocalTimeRestrictedDate&

◆ withOnlyOnDates() [1/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDates ( std::initializer_list< const char * >  dates)

Restrict to certain dates.

Parameters
datesA {} list of strings of the form YYYY-MM-DD. No other date formats are allowed!
Returns
LocalTimeRestrictedDate&

If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.

◆ withOnlyOnDates() [2/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDates ( std::initializer_list< LocalTimeYMD dates)

Restrict to certain dates.

Parameters
datesA {} list of LocalTimeYMD objects
Returns
LocalTimeRestrictedDate&

If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.

◆ withOnlyOnDays() [1/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDays ( LocalTimeDayOfWeek  value)

Restrict to days of the week.

Parameters
valueA LocalTimeDayOfWeek object specifying the days of the week (mask bits for Sunday - Saturday)
Returns
LocalTimeRestrictedDate&

A day of the week is allowed if the day of week mask bit is set. If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.

◆ withOnlyOnDays() [2/2]

LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDays ( uint8_t  mask)
inline

Restrict to certain dates.

Parameters
maskMask value, such as LocalTimeDayOfWeek::MASK_MONDAY
Returns
LocalTimeRestrictedDate&

A day of the week is allowed if the day of week mask bit is set. If a date is in the except dates list, then isValid return false. If a date is in the only on days mask OR only on dates list, then isValid will return true.


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