LocalTimeRK
Public Types | Public Member Functions | Data Fields
LocalTimeScheduleItem Class Reference

A single item in a schedule, such as minute of hour, hour of day, or a specific time. More...

#include <LocalTimeRK.h>

Public Types

enum class  ScheduleItemType : int {
  NONE = 0 , MINUTE_OF_HOUR , HOUR_OF_DAY , DAY_OF_WEEK_OF_MONTH ,
  DAY_OF_MONTH , TIME
}
 Type of schedule item this is. More...
 

Public Member Functions

 LocalTimeScheduleItem ()
 Default constructor. Set increment and optionally timeRange to use.
 
bool isValid () const
 Returns true ScheduleItemType is not NONE. More...
 
time_t getTimeSpan (const LocalTimeConvert &conv) const
 Get number of seconds in the time range at a given time. More...
 
bool getNextScheduledTime (LocalTimeConvert &conv) const
 Update the conv object to point at the next schedule item. More...
 
LocalTimeYMD getExpirationDate () const
 For restricted time ranges, get the last date (YMD) that this time range could be valid. More...
 
void fromJson (JSONValue jsonObj)
 Creates an object from JSON. More...
 

Data Fields

LocalTimeRange timeRange
 Range of local time, inclusive.
 
int increment = 0
 Increment value, or sometimes ordinal value.
 
int dayOfWeek = 0
 Used for DAY_OF_WEEK_OF_MONTH only.
 
int flags = 0
 Optional scheduling flags.
 
String name
 Optional name.
 
ScheduleItemType scheduleItemType = ScheduleItemType::NONE
 The type of schedule item.
 

Detailed Description

A single item in a schedule, such as minute of hour, hour of day, or a specific time.

Member Enumeration Documentation

◆ ScheduleItemType

enum class LocalTimeScheduleItem::ScheduleItemType : int
strong

Type of schedule item this is.

Enumerator
NONE 

No schedule defined.

MINUTE_OF_HOUR 

Minute of the hour (1)

HOUR_OF_DAY 

Hour of day (2)

DAY_OF_WEEK_OF_MONTH 

The nth day of week of the month (3)

DAY_OF_MONTH 

Day of the month (4)

TIME 

Specific time (5)

Member Function Documentation

◆ fromJson()

void LocalTimeScheduleItem::fromJson ( JSONValue  jsonObj)

Creates an object from JSON.

Parameters
jsonObjThe schedule. This should be the object containing the values, not the array.

Keys:

◆ getExpirationDate()

LocalTimeYMD LocalTimeScheduleItem::getExpirationDate ( ) const
inline

For restricted time ranges, get the last date (YMD) that this time range could be valid.

Returns
LocalTimeYMD

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

◆ getNextScheduledTime()

bool LocalTimeScheduleItem::getNextScheduledTime ( LocalTimeConvert conv) const

Update the conv object to point at the next schedule item.

Parameters
convLocalTimeConvert object, may be modified
Returns
true if there is an item available or false if not. if false, conv will be unchanged.

This method finds the next scheduled time of this item, if it's in the near future. The LocalTime::instance().getScheduleLookaheadDays() setting determines how far in the future to check; the default is 100 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.

◆ getTimeSpan()

time_t LocalTimeScheduleItem::getTimeSpan ( const LocalTimeConvert conv) const
inline

Get number of seconds in the time range at a given time.

Parameters
convThe timezone and date information for time span calculation
Returns
time_t

The conv object is necessary because getTimeSpan takes into account daylight saving transitions. When springing forward to daylight saving, from 01:15:00 to 03:15:00 is only one hour because of the DST transition.

◆ isValid()

bool LocalTimeScheduleItem::isValid ( ) const
inline

Returns true ScheduleItemType is not NONE.

Returns
true
false

This is used to check if an object was constructed by the default constructor and never set.


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