libcommonc++
0.7
|
A time specification, such as that used by cron servers. More...
#include <TimeSpec.h++>
Public Member Functions | |
TimeSpec () | |
Construct a new TimeSpec with all masks empty. More... | |
TimeSpec (const DateTime &time) | |
Construct a new TimeSpec that matches the given date/time. More... | |
TimeSpec (uint_t hour, uint_t minute) | |
Construct a new TimeSpec that matches the given hour and minute, and all possible dates. More... | |
TimeSpec (uint_t hour, uint_t minute, uint_t month, uint_t day) | |
Construct a new TimeSpec that matches the given hour, minute, month and day, and all weekdays. More... | |
TimeSpec (const String &spec) | |
Construct a new TimeSpec from the given String representation. More... | |
virtual | ~TimeSpec () |
Destructor. More... | |
void | setSpec (const String &spec) |
Set the specification according to the given String. More... | |
TimeSpec & | setMonth (uint_t month) |
Set a month in the TimeSpec. More... | |
TimeSpec & | setMonths (uint_t month1, uint_t month2) |
Set a range of months in the TimeSpec. More... | |
TimeSpec & | clearMonth (uint_t month) |
Clear a month in the TimeSpec. More... | |
TimeSpec & | clearMonths (uint_t month1, uint_t month2) |
Clear a range of months in the TimeSpec. More... | |
TimeSpec & | setAllMonths () |
Set all of the months in the TimeSpec. More... | |
TimeSpec & | clearAllMonths () |
Clear all of the months in the TimeSpec. More... | |
TimeSpec & | setDay (uint_t day) |
Set a day in the TimeSpec. More... | |
TimeSpec & | setDays (uint_t day1, uint_t day2) |
Set a range of days in the TimeSpec. More... | |
TimeSpec & | clearDay (uint_t day) |
Clear a day in the TimeSpec. More... | |
TimeSpec & | clearDays (uint_t day1, uint_t day2) |
Clear a range of days in the TimeSpec. More... | |
TimeSpec & | setAllDays () |
Set all of the days in the TimeSpec. More... | |
TimeSpec & | clearAllDays () |
Clear all of the days in the TimeSpec. More... | |
TimeSpec & | setDayOfWeek (uint_t dow) |
Set a weekday in the TimeSpec. More... | |
TimeSpec & | setDaysOfWeek (uint_t dow1, uint_t dow2) |
Set a range of weekdays in the TimeSpec. More... | |
TimeSpec & | clearDayOfWeek (uint_t dow) |
Clear a weekday in the TimeSpec. More... | |
TimeSpec & | clearDaysOfWeek (uint_t dow1, uint_t dow2) |
Clear a range of weekdays in the TimeSpec. More... | |
TimeSpec & | setAllDaysOfWeek () |
Set all of the weekdays in the TimeSpec. More... | |
TimeSpec & | clearAllDaysOfWeek () |
Clear all of the weekdays in the TimeSpec. More... | |
TimeSpec & | setHour (uint_t hour) |
Set an hour in the TimeSpec. More... | |
TimeSpec & | setHours (uint_t hour1, uint_t hour2) |
Set a range of hours in the TimeSpec. More... | |
TimeSpec & | clearHour (uint_t hour) |
Clear an hour in the TimeSpec. More... | |
TimeSpec & | clearHours (uint_t hour1, uint_t hour2) |
Clear a range of hours in the TimeSpec. More... | |
TimeSpec & | setAllHours () |
Set all of the hours in the TimeSpec. More... | |
TimeSpec & | clearAllHours () |
Clear all of the hours in the TimeSpec. More... | |
TimeSpec & | setMinute (uint_t minute) |
Set a minute in the TimeSpec. More... | |
TimeSpec & | setMinutes (uint_t minute1, uint_t minute2) |
Set a range of minutes in the TimeSpec. More... | |
TimeSpec & | clearMinute (uint_t minute) |
Clear a minute in the TimeSpec. More... | |
TimeSpec & | clearMinutes (uint_t minute1, uint_t minute2) |
Clear a range of minutes in the TimeSpec. More... | |
TimeSpec & | setAllMinutes () |
Set all of the minutes in the TimeSpec. More... | |
TimeSpec & | clearAllMinutes () |
Clear all of the minutes in the TimeSpec. More... | |
bool | matches (time_s_t time) const |
Test if the TimeSpec matches the given time. More... | |
bool | matches (time_ms_t time) const |
Test if the TimeSpec matches the given time. More... | |
bool | matches (uint_t month, uint_t day, uint_t weekday, uint_t hour, uint_t minute) const |
Test if the TimeSpec matches the given time. More... | |
String | toString () const |
Get a String representation of the TimeSpec. More... | |
A time specification, such as that used by cron servers.
The TimeSpec can be thought of as an expression for matching against dates/times, down to a one-minute resolution, which is adequate for most automated task scheduling. The TimeSpec maintains a list of bitmasks representing all possible hours of the day, minutes of the hour, days of the week, days of the month, and months of the year. Individual minutes, hours, days, weekdays, and months can be toggled "on" or "off" in the TimeSpec. The TimeSpec can then be compared against a time value; if the hour, minute, day, weekday, and month components of that time correspond to bits that are "on" in the corresponding bitmasks, then the match is successful.
A TimeSpec can be represented in textual form as five tokens separated by spaces; these five tokens correspond to the minute, hour, day, month, and weekday values that are set in the corresponding masks. Each of these tokens may consist of a comma-separated series of wildcards (denoted by an asterisk '*'), single values, or value ranges, the latter being defined as two integers separated by a dash ('-'). For example, the specification:
0 * 1-5,7 * 0
represents a TimeSpec that matches every hour, on the hour, on the first through fifth or the seventh day of any month, but only if it is a Sunday.
Construct a new TimeSpec that matches the given hour and minute, and all possible dates.
Construct a new TimeSpec that matches the given hour, minute, month and day, and all weekdays.
|
virtual |
Destructor.
Clear a range of weekdays in the TimeSpec.
If the range is invalid, the TimeSpec is not changed.
dow1 | The start weekday, a value from 0 to 7, inclusive, where both 0 and 7 indicate Sunday, and the remaining values indicate the number of days since Sunday. |
dow2 | The end weekday, a value from 0 to 7, inclusive, where both 0 and 7 indicate Sunday, and the remaining values indicate the number of days since Sunday. |
bool matches | ( | time_s_t | time | ) | const |
Test if the TimeSpec matches the given time.
time | The time to compare against. |
bool matches | ( | time_ms_t | time | ) | const |
Test if the TimeSpec matches the given time.
time | The time to compare against. |
Test if the TimeSpec matches the given time.
month | The month. |
day | The day. |
weekday | The weekday. |
hour | The hour. |
minute | The minute. |
Set a range of weekdays in the TimeSpec.
If the range is invalid, the TimeSpec is not changed.
dow1 | The start weekday, a value from 0 to 7, inclusive, where both 0 and 7 indicate Sunday, and the remaining values indicate the number of days since Sunday. |
dow2 | The end weekday, a value from 0 to 7, inclusive, where both 0 and 7 indicate Sunday, and the remaining values indicate the number of days since Sunday. |