LocalTimeRK
|
Timezone and DST handling for Particle devices
This library is designed for specific local time and daylight saving time scenarios on Particle devices. It is not intended to solve all problems in all situations, however it will work well in certain scenarios:
What it's good for:
What it's not intended for:
For the United States east coast, the configuration string is:
What this means is:
There are a bunch of supported formats, including for locations that don't have DST (such as Arizona, "MST7") and southern hemisphere where daylight saving is on the opposite part of the year, such as Eastern Australian time used in Sydney, Australia "AEST-10AEDT,M10.1.0/02:00:00,M4.1.0/03:00:00".
This library does not modify the Time
class timezone! This has the potential to disrupt all sorts of things that depend on Time
, and should be avoided. A new class and methods provide access to local time when needed.
Additionally, it's designed to handle scheduling. For example, say you want to perform an operation at 3:00 AM every day, local time. The class can find the UTC time corresponding to this, taking into account timezones and DST changes. Using Time.now()
comparisons (at UTC) is fast and efficient. It's also good when you want to store the desired time in EEPROM, retained memory, or the file system.
The library also handles weird transition scenarios that occur on spring forward (in the north hemisphere) where the hour from 2:00 AM local time to 2:59:59 doesn't exist, and in the fall back where the hour from 1:00:00 to 1:59:59 local time occurs twice.
It also handles other common scheduling scenarios:
There is an example of using the library to use an Adafruit FeatherWing OLED Display 128x32 as a clock.
The display is available at Adafruit. You can find more technical information at Adafruit. The library is available in the Web IDE as oled-wing-adafruit. You can find additional documentation here.
The code example is in the more-examples directory in the Clock directory and is quite simple:
Some configuration strings:
Location | Timezone Configuration |
---|---|
New York | "EST5EDT,M3.2.0/02:00:00,M11.1.0/02:00:00" |
Chicago | "CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00" |
Denver | "MST7MDT,M3.2.0/2:00:00,M11.1.0/2:00:00" |
Phoenix | "MST7" |
Los Angeles | "PST8PDT,M3.2.0/2:00:00,M11.1.0/2:00:00" |
London | "BST0GMT,M3.5.0/1:00:00,M10.5.0/2:00:00" |
Sydney, Australia | "AEST-10AEDT,M10.1.0/02:00:00,M4.1.0/03:00:00" |
Adelaide, Australia | "ACST-9:30ACDT,M10.1.0/02:00:00,M4.1.0/03:00:00" |
UTC | "UTC" |
Use the LocalTimeConvert
class like this to get the current time:
This will initialize the conv
object with information about the current local time in the timezone you have configured.
Additional useful LocalTimeConvert methods:
<details>
Returns true if the current time is in daylight saving time.
Returns true of the current time in in standard time.
Works like Time.timeStr() to generate a readable string of the local time.
Uses asctime formatting, which looks like "Fri Jan 1 18:45:56 2021". The strings are not localized; they're always in English.
Works like Time.format()
formatSpec
the format specifies, which can beThere are many options to strftime described here: https://www.cplusplus.com/reference/ctime/strftime/?kw=strftime
Unlike Time.format(), you can use Z to output the timezone abbreviation, for example "EDT" for the Eastern United States, daylight saving instead of -04:00.
The z formatting matches that of Time.format(), which is wrong. The correct output should be "-400" but the output will be "-04:00" for compatibility.
If you want to make a US-style AM/PM clock display, the formatting string "%I:%M %p" will produce something like "12:30 PM".
Returns the abbreviated time zone name for the current time.
For example, for the United States east coast, EST or EDT depending on whether the current time is DST or not. See also isDST().
This string comes from the LocalTimePosixTimezone object.
Use the LocalTimeConvert
class like this to get the current time:
</details>
An advanced scheduling mode was added in version 0.0.8. This allows complex schedules such as:
This can either be specified in code, or it can be expressed in JSON. JSON allows the schedule to be updating using a Particle.function, for example.
This is a compact representation of that schedule in 77 bytes of JSON data:
While scheduling is designed to work with local time, each schedule calculator can optionally have a time zone override, which makes it possible to do some calculations at UTC if you prefer to do that.
This is the code in examples/2-schedule:
This is a simple example that publishes at :00, :05, :10, .... Note that these are clock times, not rolling times.
Technically you don't need a timezone for this example since it doesn't do any hour-based calculations, but it's set using withConfig()
when you need to use one.
The part in loop() tests to see if it's time to publish and then publishes. As shown in the example, if you are not connected to the cloud at the scheduled time, that scheduled time is skipped.
If you reverse the order in the if statement, then if you are not connected to the cloud, it's possible to get publish immediately after reconnecting to the cloud to make up for the one that was missed.
The real benefit is when you start to make more complex schedules, such as:
You can exclude dates from a schedule. For example, the every 15 minutes on weekdays schedule excludes Monday, April 11, 2022 with this schedule:
LocalTimeSchedule include things like every n minutes, every n hours, as well as day of week and day of month multiples. Each multiple has a type, an increment, in some cases additional data, and a LocalTimeRange
that determines when the multiple is used.
LocalTimeRange
is itself composed of a TimeRange
, and a LocalTimeRestrictedDate
. This specifies both the time of day, as well as an optional restriction on the dates it applies. See above for for an explanation of these types.
This schedule item is used for "every n minutes." For example, if you want to publish an event every 15 minutes.
LocalTimeRange
can restrict this to certain hours of the day, and certain days of the week. It can also handle exception dates, both only on date, or to exclude dates.For example, every 15 minutes all day, at 05:00, 20:00, 35:00, 50:00:
Every 5 minutes from 9:00 AM to 5:00 PM local time every day:
Every 5 minutes from 9:00 AM to 5:00 PM local time on weekdays (not Saturday or Sunday):
In generating from JSON:
Key | Type | Description | Default |
---|---|---|---|
"mh" | integer | Minute of hour multiple | |
"f" | integer | Flag bits (optional) | 0 |
"s" | string | The start time (HH:MM:SS format, can omit MM or SS) | "00:00:00" |
"e" | string | The end time (HH:MM:SS format, can omit MM or SS) | "23:59:59" |
| "y" | integer | Mask value for days of the week (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
This schedule is used for "every n hours." For example, if you want to wake and publish every 4 hours.
LocalTimeRange
can restrict this to certain hours of the day, and certain days of the week. It can also handle exception dates, both only on date, or to exclude dates.For example, every 2 hours (00:00, 02:00, 04:00) local time.
Every 2 hours, but starting at 01:30 local time (01:30, 03:30, 05:03, ...).
Every 15 minutes between 9:00 AM and 5:00 PM local time, otherwise every 2 hours (00:00, 02:00, 04:00 local time)
If configuring by JSON:
Key | Type | Description | Default |
---|---|---|---|
"hd" | integer | Hour of day multiple | |
"f" | integer | Flag bits (optional) | 0 |
"s" | string | The start time (HH:MM:SS format, can omit MM or SS) | "00:00:00" |
"e" | string | The end time (HH:MM:SS format, can omit MM or SS) | "23:59:59" |
| "y" | integer | Mask value for days of the week (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
This is used for things like: "Every first Monday of the month," "Every second Tuesday of the month," or "Last Friday of the month."
LocalTimeRange
can restrict this to certain hours of the day, and certain days of the week. It can also handle exception dates, both only on date, or to exclude dates.First Saturday of the month at midnight local time:
First Monday of the month at 9:00 AM local time:
Last Friday of the month at 5 PM local time.
Key | Type | Description | Default |
---|---|---|---|
"dw" | integer | Day of week instance (1 = first, 2 = second, ..., or -1 = last, -2 = second to last, ... |
| "d" | integer | Day of the week 0 = Sunday, 1 = Monday, ..., 6 = Saturday | | "f" | integer | Flag bits (optional) | 0 | | "s" | string | The start time (HH:MM:SS format, can omit MM or SS) | "00:00:00" | | "e" | string | The end time (HH:MM:SS format, can omit MM or SS) | "23:59:59" | | "y" | integer | Mask value for days of the week (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
This is used for things like "The 1st of the month," "The 15th of the month," or "the last day of the month."
LocalTimeRange
can handle exception dates, both only on date, or to exclude dates.For example, the 6th of the month at midnight:
The 6th of the month at 6:00 AM local time:
The last day of the month at 11:59:59 PM:
The second to last day of the month:
Key | Type | Description | Default |
---|---|---|---|
"dw" | integer | Day of month instance (1 = 1st, 2 = 2nd, ... or -1 = last day of month, -2 = second to last, ... | |
"f" | integer | Flag bits (optional) | 0 |
"s" | string | The start time (HH:MM:SS format, can omit MM or SS) | "00:00:00" |
"e" | string | The end time (HH:MM:SS format, can omit MM or SS) | "23:59:59" |
| "y" | integer | Mask value for days of the week (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
It's also possible to schedule at a specific time in local time. You can specify zero or more LocalTimeHMSRestricted
objects, limited by available RAM.
The LocalTimeHMSRestricted
is itself composed of a LocalTimeHMS
object, for hours minutes and seconds, and a LocalTimeRestrictedDate
which can optionally restrict which dates the times re used.
Some ways you can use times:
At 4:00 AM local time, every day:
At 06:00 and 18:30 (4:30 PM) local time, every day. Note the {} surrounding a list of times.
At 4:00 AM on weekdays:
At midnight (local time) on Saturdays:
If configuring by JSON:
| Key | Type | Description | Default | | :— | :— | :— | :— | | "tm" | string | Time in "HH:MM:SS" format, 24 hour clock, local time | | "f" | integer | Flag bits (optional) | 0 | | "y" | number | Mask value for days of the week (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
<details>
A complete time schedule.
A time schedule consists of minute multiples ("every 15 minutes"), optionally within a time range (all day, or from 09:00:00 to 17:00:00 local time, for example.
It can also have hour multiples, optionally in a time range, at a defined minute ("every 4 hours at :15 past the hour").
Schedules can be at a specifc day week, with an ordinal (first Monday, last Friday) at a specific time, optionally with exceptions.
Schedules can be a specific day of the month (the 1st, the 5th of the month, the last day of the month, the second to last day of month).
It can also have any number of specific times in the day ("at 08:17:30 local time, 18:15:20 local time") every day, specific days of the week, on specific dates, or with date exceptions.
Adds a minute multiple schedule in a time range.
increment
Number of minutes (must be 1 <= minutes <= 59). A value that is is divisible by is recommended.timeRange
When to apply this minute multiple and/or minute offset (optional)This schedule publishes every n minutes within the hour. This really is every hour, not rolling, so you should use a value that 60 is divisible by (2, 3, 4, 5, 6, 10, 12, 15, 20, 30) otherwise there will be an inconsistent period at the top of the hour.
If you specify a time range that does not start at 00:00:00 you can customize which minute the schedule starts at. For example: 15, LocalTimeRange(LocalTimeHMS("00:05:00"), LocalTimeHMS("23:59:59")
will schedule every 15 minutes, but starting at 5 minutes past the hour, so 05:00, 20:00, 35:00, 50:00.
The largest value for hmsEnd of the time range is 23:59:59.
Adds multiple times periodically in a time range with an hour increment.
hourMultiple
Hours between items must be >= 1. For example: 2 = every other hour.timeRange
Time range to add items to. This is optional; if not specified then the entire day. Also is used to specify a minute offset.Hours are per day, local time. For whole-day schedules, you will typically use a value that 24 is evenly divisible by (2, 3, 4, 6, 8, 12), because otherwise the time periods will brief unequal at midnight.
Also note that times are local, and take into account daylight saving. Thus during a time switch, the interval may end up being a different number of hours than specified. For example, if the times would have been 00:00 and 04:00, a hourMultiple of 4, and you do this over a spring forward, the actual number hours between 00:00 and 04:00 is 5 (at least in the US where DST starts at 2:00).
Schedule an item on a specific instance of a day of week of the month.
dayOfWeek
Day of week 0 = Sunday, 1 = Monday, ..., 6 = Saturdayinstance
1 = first week, 2 = second week, ..., -1 = last week, -2 = 2nd to last weektimeRange
Optional to restrict dates or to set a time for the itemSchedule an item on a specific day of the month.
dayOfMonth
1 = 1st, 2 = 2nd of the month, ..., -1 = last day of the month, -2 = second to last day of the month, ...timeRange
Optional to restrict dates or to set a time for the itemAdd a scheduled item at a time in local time during the day.
hms
The time in local time 00:00:00 to 23:59:59, optionally with date restrictionsYou can call this multiple times, and also combine it with minute multiple schedules.
Add multiple scheduled items at a time in local time during the day.
timesParam
an auto-initialized list of LocalTimeHMS objectsYou can call this multiple times, and also combine it with minute multiple schedules.
schedule.withTimes({LocalTimeHMS("06:00"), LocalTimeHMS("18:30")});
Sets the name of this schedule (optional)
name
Sets the flags for this schedule (optional)
flags
Returns true if the schedule does not have any items in it.
true
false
Clear the existing settings.
Set the schedule from a JSON string containing an array of objects.
jsonStr
See the overload that takes a JSONValue if the JSON string has already been parsed.
Set the schedule of this object from a JSONValue, typically the outer object.
jsonArray
A JSONValue containing an array of objectsArray of LocalTimeScheduleItem objects:
Update the conv object to point at the next schedule item.
conv
LocalTimeConvert object, may be modifiedtrue if there is an item available or false if not. if false, conv will be unchanged.
This method finds closest scheduled time for this objecvt, if it's in the near future. The LocalTime::instance().getScheduleLookaheadDays() setting determines how far in the future to check; the default is 3 days. The way schedules work each day needs to be checked to make sure all of the constraints are met, so long look-aheads are computationally intensive. This is not normally an issue, because the idea is that you'll wake from sleep or check the schedule at least every few days, at which point the new schedule may be available.
Update the conv object to point at the next schedule item.
conv
LocalTimeConvert object, may be modifiedfilter
A function to determine, for each schedule item, if it should be testedtrue if there is an item available or false if not. if false, conv will be unchanged.
This method finds closest scheduled time for this objecvt, if it's in the near future. The LocalTime::instance().getScheduleLookaheadDays() setting determines how far in the future to check; the default is 3 days. The way schedules work each day needs to be checked to make sure all of the constraints are met, so long look-aheads are computationally intensive. This is not normally an issue, because the idea is that you'll wake from sleep or check the schedule at least every few days, at which point the new schedule may be available.
The filter function or lambda has this prototype:
bool filterCallback(LocalTimeScheduleItem &item)
If should return true to check this item, or false to skip this item for schedule checking.
</details>
This object holds a hour, minute, and second value (HMS). There are numerous methods to compare time values, and convert the values to other formats.
When converting from string format always use 24-hour clock format; this object does not support AM/PM. Also when converting from strings you can omit the seconds, or even both the minutes and seconds.
Note that hour 24 is never a valid value. Because HMS calculations are always inclusive, the end of the day is 23:59:59. Leap seconds are not supported by the underlying C standard time library.
<details>
Default constructor. Sets time to 00:00:00.
Destructor.
Constructs the object from a time string.
str
The time stringThe time string is normally of the form HH:MM:SS, such as "04:00:00" for 4:00 AM. The hour is in 24-hour format. Other formats are supported as well, including omitting the seconds (04:00), or including only the hour "04", or omitting the leadings zeros (4:0:0).
Additionally, the hour could be negative, used in UTC DST offsets. The minute and second are always positive (0-59). The hour could also be > 24 when used as a timezone offset.
Construct this HMS from a LocalTimeValue (which contains YMD and HMS)
value
Sets the hour, minute, and second to 0.
Parse a "H:MM:SS" string.
str
Input stringMultiple formats are supported, and parts are optional:
Hours are always 0 - 23 (24-hour clock). Can also be a negative hour -1 to -23.
Turns the parsed data into a normalized string of the form: "HH:MM:SS" (24-hour clock, with leading zeroes)
Convert hour minute second into a number of seconds (simple multiplication and addition)
Sets the hour, minute, and second fields from a struct tm.
Sets the HMS from a LocalTimeValue.
value
Fill in the tm_hour, tm_min, and tm_sec fields of a struct tm from the values in this object.
pTimeInfo
The struct tm to modifyAdjust the values in a struct tm from the values in this object.
pTimeInfo
The struct tm to modifyAfter calling this, the values in the struct tm may be out of range, for example tm_hour > 23. This is fine, as calling mktime/gmtime normalizes this case and carries out-of-range values into the other fields as necessary.
Parses a JSON value of type string in HH:MM:SS format.
jsonObj
Sets this object to be the specified hour, with minute and second set to 0.
hour
0 <= hour < 24Sets this object to be the specified hour and minute, with second set to 0.
hour
0 <= hour < 24minute
0 <= minute < 60Compare two LocalTimeHMS objects.
other
The item to compare toint -1 if this item is < other; 0 if this = other, or +1 if this > other
Returns true if this item is equal to other. Compares hour, minute, and second.
other
true
false
Returns true if this item is not equal to other.
other
true
false
Returns true if this item is < other.
other
true
false
Returns true if this item is > other.
other
true
false
Returns true if this item <= other.
other
true
false
Returns true if this item is >= other.
other
true
false
</details>
This object specifies a year, month, and day. There are numerous methods to compare time values, and convert the values to other formats.
When converting from a string this must always be "YYYY-MM-DD" format, with dashes, and in that order. Other date formats including common but poorly defined United States date formats cannot be used!
<details>
Class for holding a year month day efficiently (4 bytes of storage)
There is no method to get this object from a time_t because time_t is at UTC and this object is intended to be the YMD at local time to correspond with a LocalTimeHMS. Thus it requires a LocalTimeConvert object, and there is a method to get a LocalTimeYMD from a LocalTimeConvert, not from this object.
Default contructor with an invalid date (0000-00-00) set.
Construct a YMD value from a string.
s
String, must be in YYYY-MM-DD format. No other formars are allowed!Construct from a LocalTimeValue object.
value
The date to copy fromReturns true if the date is uninitialized, as from the default constructor.
true
false
Get the year as a 4-digit year, for example: 2022.
int The year, 4-digit
Set the year value.
year
Year to set, can be several different values but typically is 4-digit year (2022, for example)Get the month, 1 - 12 inclusive.
int month
Set the month, 1 - 12 inclusive.
month
Month valueGet the day of month, starting a 1.
int
Set the day of the month, staring at 1.
day
This method does not validate the date value, but you should avoid setting invalid date values since the results can be unpredictable.
Copies the year, month, and day from a struct tm.
pTimeInfo
The pointer to a struct tm to copy the year, month, and day from.The tm should be in local time.
The LocalTimeValue to copy the year, month and day from.
value
Source of the year, month, and day valuesSince LocalTimeValue contains a struct tm, this uses fromTimeInfo internally.
Add a number of days to the current YMD (updating month or year as necessary)
numberOfDays
Number of days to add (positive) or subtract (negative)Works correctly with leap years.
Get the day of the week, 0 = Sunday, 1 = Monday, 2 = Tuesday, ..., 6 = Saturday.
int the day of the week
Compare to another LocalTimeYMD object.
other
int -1 if this is < other, 0 if this == other, or 1 if this > other.
Tests if this LocalTimeYMD is equal to other.
other
true
false
Tests if this LocalTimeYMD is not equal to other.
other
true
false
Tests if this LocalTimeYMD is less than other.
other
true
false
Tests if this LocalTimeYMD is less than or equal to other.
other
true
false
Tests if this LocalTimeYMD is greater than other.
other
true
false
Tests if this LocalTimeYMD is greater than or equal to other.
other
true
false
Parse a YMD string in the format "YYYY-MD-DD". Only this format is supported!
s
true
false
Do not use this function with other date formats like "mm/dd/yyyy"!
Converts the value to YYYY-MM-DD format as a String with leading zeros.
String
Packed structure to hold the YMD value.
</details>
A LocalTimeRange
is a start time and end time in local time, expressed as LocalTimeHMS
objects (hours, minutes, seconds).
Time ranges are inclusive, so the entire day is 00:00:00 to 23:59:59.
The default constructor for LocalTimeRange
sets the time range to the entire day.
When converting from JSON:
Key | Type | Description | Default |
---|---|---|---|
"s" | string | Starting time in "HH:MM:SS" format, 24 hour clock, local time | "00:00:00" |
"e" | string | Ending time in "HH:MM:SS" format, 24 hour clock, local time | "23:59:59" |
<details>
Construct a new Time Range object with the range of the entire day (inclusive)
This is start = 00:00:00, end = 23:59:59. The system clock does not have a concept of leap seconds.
Construct a new Time Range object with the specifies start and end times.
hmsStart
Start time in local time 00:00:00 <= hmsStart <= 23:59:59hmsEnd
End time in local time 00:00:00 <= hmsStart <= 23:59:59 (optional)Note that 24:00:00 is not a valid time. You should generally use inclusive times such that 23:59:59 is the end of the day.
Construct a new object that specifies start time, end time, and date restrictions.
hmsStart
Start time in local time 00:00:00 <= hmsStart <= 23:59:59hmsEnd
End time in local time 00:00:00 <= hmsStart <= 23:59:59dateRestriction
Only use this time range on certain datesClear time range to all day, every day.
Get the number of seconds between start and end based on a LocalTimeConvert object.
The reason for the conv object is that it contains the time to calculate at, as well as the daylight saving time settings. This methods takes into account the actual number of seconds including when a time change is crossed.
conv
The time and timezone settings to calculate the time span attime_t Time difference in seconds
In the weird case that start > end, it can return a negative value, as time_t is a signed long (or long long) value.
This does not take into account date restrictions!
Compares a time (LocalTimeHHS, local time) to this time range.
hms
int -1 if hms is before hmsStart, 0 if in range, +1 if hms is after hmsEnd
Returns true if the date restrictions allow this day.
ymd
true
false
Returns true if the date restrictions allow this date and the time is in this range (inclusive)
localTimeValue
true
false
Set the date restrictions from a LocalTimeHMSRestricted object.
hms
LocalTimeHMSRestricted, really only uses the date restrictions, not the HMS partFills in the time range from a JSON object.
jsonObj
Keys:
</details>
A LocalTimeDayOfWeek
specifies zero or more days of the week (Sunday, Monday, ...)
Common mask values:
| Value Hex | Value Decimal | Constant | Description | | :— | —: | :— | | 0x01 | 1 | MASK_SUNDAY | Sunday | | 0x02 | 2 | MASK_MONDAY | Monday | | 0x04 | 4 | MASK_TUESDAY | Tuesday | | 0x08 | 8 | MASK_WEDNESDAY | Wednesday | | 0x10 | 16 | MASK_THURSDAY | Thursday | | 0x20 | 32 | MASK_FRIDAY | Friday | | 0x40 | 64 | MASK_SATURDAY | Saturday | | 0x7f | 127 | MASK_ALL | Every day | | 0x3e | 62 | MASK_WEEKDAY | Weekdays (Monday - Friday) | | 0x41 | 65 | MASK_WEEKEND | Weekends (Saturday - Sunday) |
Note that you can combine any mask bits. For example, Monday, Wednesday, Friday is 2 + 8 + 32 = 42,
In JSON, you can only use the numeric mask values, as a decimal number. For example, weekdays Monday - Friday is 62.
Key | Type | Description |
---|---|---|
"y" | number | Mask value for days of the week, see table above |
A LocalTimeRestrictedDate
is used for both multiples and times (below). It can have:
LocalTimeDayOfWeek
), which is a bitmask of days to allow. This makes it easy to specify, for example, weekdays (Monday - Friday).LocalTimeYMD
)LocalTimeYMD
)| Key | Type | Description | Default | | :— | :— | :— | :— | | "y" | number | Mask value for days of the week, see table above (optional) | | "a" | Array of string | Array of strings of the form YYYY-MM-DD to allow specific dates (optional) | | "x" | Array of string | Array of strings of the form YYYY-MM-DD to exclude specific dates (optional) |
<details>
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)Construct an object with an initializer list of strings.
mask
mask value, see LocalTimeDayOfWeek for valuesonlyOnDates
Initializer list of strings of the form YYYY-MM-DDexceptDates
Initializer list of strings of the form YYYY-MM-DDConstruct an object with an initializer list of LocalTimeYMD objects.
mask
mask value, see LocalTimeDayOfWeek for valuesonlyOnDates
Initializer list of LocalTimeYMD valuesexceptDates
Initializer list of LocalTimeYMD valuesSet the mask value to MASK_ALL. Does not change only on date or except on date lists.
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.
Restrict to certain dates.
mask
Mask value, such as LocalTimeDayOfWeek::MASK_MONDAYA 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.
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.
Restrict to certain dates.
dates
A {} list of LocalTimeYMD objectsIf 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.
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.
Dates that will always return false for isValid.
dates
A {} list of LocalTimeYMD objectsIf 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.
Returns true if onlyOnDays mask is 0 and the onlyOnDates and exceptDates lists are empty.
true
false
Clear all settings.
Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.
localTimeValue
Date to check (local time)true
false
Returns true if a date is in the onlyOnDays or onlyOnDates list, and not in the exceptDates list.
ymd
Date to check (local time)true
false
Returns true of a date is in the onlyOnDates list.
ymd
true
false
Returns true of a date is in the exceptDates list.
ymd
true
false
Fills in this object from JSON data.
jsonObj
Keys:
A complete time schedule.
A time schedule consists of minute multiples ("every 15 minutes"), optionally within a time range (all day, or from 09:00:00 to 17:00:00 local time, for example.
It can also have hour multiples, optionally in a time range, at a defined minute ("every 4 hours at :15 past the hour").
Schedules can be at a specifc day week, with an ordinal (first Monday, last Friday) at a specific time, optionally with exceptions.
Schedules can be a specific day of the month (the 1st, the 5th of the month, the last day of the month, the second to last day of month).
It can also have any number of specific times in the day ("at 08:17:30 local time, 18:15:20 local time") every day, specific days of the week, on specific dates, or with date exceptions.
</details>