LocalTimeRK
|
Day of week, date, or date exception restrictions. More...
#include <LocalTimeRK.h>
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... | |
LocalTimeRestrictedDate & | withOnAllDays () |
Set the mask value to MASK_ALL. Does not change only on date or except on date lists. More... | |
LocalTimeRestrictedDate & | withOnlyOnDays (LocalTimeDayOfWeek value) |
Restrict to days of the week. More... | |
LocalTimeRestrictedDate & | withOnlyOnDays (uint8_t mask) |
Restrict to certain dates. More... | |
LocalTimeRestrictedDate & | withOnlyOnDates (std::initializer_list< const char * > dates) |
Restrict to certain dates. More... | |
LocalTimeRestrictedDate & | withOnlyOnDates (std::initializer_list< LocalTimeYMD > dates) |
Restrict to certain dates. More... | |
LocalTimeRestrictedDate & | withExceptDates (std::initializer_list< const char * > dates) |
Dates that will always return false for isValid. More... | |
LocalTimeRestrictedDate & | withExceptDates (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< LocalTimeYMD > | onlyOnDates |
Dates to allow. | |
std::vector< LocalTimeYMD > | exceptDates |
Dates to exclude. | |
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.
|
inline |
Create a date restricted object restricted to days of the week.
mask | The days of the week to enable. Pass LocalTimeDayOfWeek::MASK_ALL to allow on every day (no restrictions) |
|
inline |
Construct an object with an initializer list of strings.
mask | mask value, see LocalTimeDayOfWeek for values |
onlyOnDates | Initializer list of strings of the form YYYY-MM-DD |
exceptDates | Initializer list of strings of the form YYYY-MM-DD |
|
inline |
Construct an object with an initializer list of LocalTimeYMD objects.
mask | mask value, see LocalTimeDayOfWeek for values |
onlyOnDates | Initializer list of LocalTimeYMD values |
exceptDates | Initializer list of LocalTimeYMD values |
void LocalTimeRestrictedDate::fromJson | ( | JSONValue | jsonObj | ) |
Fills in this object from JSON data.
jsonObj |
Keys:
LocalTimeYMD LocalTimeRestrictedDate::getExpirationDate | ( | ) | const |
Get the last date (YMD) that this restricted date could be valid.
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.
bool LocalTimeRestrictedDate::inExceptDates | ( | LocalTimeYMD | ymd | ) | const |
Returns true of a date is in the exceptDates list.
ymd |
bool LocalTimeRestrictedDate::inOnlyOnDates | ( | LocalTimeYMD | ymd | ) | const |
Returns true of a date is in the onlyOnDates list.
ymd |
bool LocalTimeRestrictedDate::isEmpty | ( | ) | const |
Returns true if onlyOnDays mask is 0 and the onlyOnDates and exceptDates lists are empty.
bool LocalTimeRestrictedDate::isValid | ( | LocalTimeValue | localTimeValue | ) | const |
Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.
localTimeValue | Date to check (local time) |
bool LocalTimeRestrictedDate::isValid | ( | LocalTimeYMD | ymd | ) | const |
Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.
ymd | Date to check (local time) |
LocalTimeRestrictedDate & LocalTimeRestrictedDate::withExceptDates | ( | std::initializer_list< const char * > | dates | ) |
Dates that will always return false for isValid.
dates | A {} list of strings of the form YYYY-MM-DD. No other date formats are allowed! |
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.
LocalTimeRestrictedDate & LocalTimeRestrictedDate::withExceptDates | ( | std::initializer_list< LocalTimeYMD > | dates | ) |
Dates that will always return false for isValid.
dates | A {} list of LocalTimeYMD objects |
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.
|
inline |
Set the mask value to MASK_ALL. Does not change only on date or except on date lists.
LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDates | ( | std::initializer_list< const char * > | dates | ) |
Restrict to certain dates.
dates | A {} list of strings of the form YYYY-MM-DD. No other date formats are allowed! |
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.
LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDates | ( | std::initializer_list< LocalTimeYMD > | dates | ) |
Restrict to certain dates.
dates | A {} list of LocalTimeYMD objects |
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.
LocalTimeRestrictedDate & LocalTimeRestrictedDate::withOnlyOnDays | ( | LocalTimeDayOfWeek | value | ) |
Restrict to days of the week.
value | A LocalTimeDayOfWeek object specifying the days of the week (mask bits for Sunday - Saturday) |
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.
|
inline |
Restrict to certain dates.
mask | Mask value, such as LocalTimeDayOfWeek::MASK_MONDAY |
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.