AceTime
1.1.2
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
|
Represents a period of time relative to some known point in time, potentially represented by a DateTime. More...
#include <TimePeriod.h>
Public Member Functions | |
TimePeriod (uint8_t hour, uint8_t minute, uint8_t second, int8_t sign=1) | |
Constructor. More... | |
TimePeriod (int32_t seconds=0) | |
Constructor from number of seconds. More... | |
uint8_t | hour () const |
Return the hour. | |
void | hour (uint8_t hour) |
Set the hour. | |
uint8_t | minute () const |
Return the minute. | |
void | minute (uint8_t minute) |
Set the minute. | |
uint8_t | second () const |
Return the second. | |
void | second (uint8_t second) |
Set the second. | |
int8_t | sign () const |
Return the sign bit. | |
void | sign (int8_t sign) |
Set the sign bit. More... | |
int32_t | toSeconds () const |
Convert to number of seconds. More... | |
int8_t | compareTo (const TimePeriod &that) const |
Compare this TimePeriod with another TimePeriod and return (<0, 0, >0) according to (a<b, a==b, a>b). | |
void | printTo (Print &printer) const |
Print to given printer. More... | |
TimePeriod (const TimePeriod &)=default | |
TimePeriod & | operator= (const TimePeriod &)=default |
Friends | |
bool | operator== (const TimePeriod &a, const TimePeriod &b) |
Return true if two TimePeriod objects are equal. More... | |
Represents a period of time relative to some known point in time, potentially represented by a DateTime.
Each component (hour, minute, second) is stored as an unsigned byte (uint8_t). The sign bit allows forward and backward time periods to be represented.
Definition at line 22 of file TimePeriod.h.
|
inlineexplicit |
Constructor.
hour | hour (0-255) |
minute | minute (0-59) |
second | second (0-59) |
sign | The sign bit. Should be either +1 or -1, but in practice, anything greater than equal to 0 will be considered to be +1, and anything less than zero will be considered -1. |
Definition at line 34 of file TimePeriod.h.
|
inlineexplicit |
Constructor from number of seconds.
The largest valid 'seconds' is +/- 921599 corresponding to (hour=255, minute=59, second=59). For larger numbers, the 'hour' component will be truncated.
seconds | number of seconds (default 0) |
Definition at line 48 of file TimePeriod.h.
void ace_time::TimePeriod::printTo | ( | Print & | printer | ) | const |
Print to given printer.
If the time period is negative, a minus sign is prepended. This class does not implement the Printable interface to avoid increasing the size of the object from the additional virtual function.
Definition at line 13 of file TimePeriod.cpp.
|
inline |
Set the sign bit.
Should be either +1 or -1, but in practice, anything greater than equal to 0 will be considered to be +1, and anything less than zero will be considered -1.
Definition at line 88 of file TimePeriod.h.
|
inline |
Convert to number of seconds.
The largest/smallest possible value returned by this method is +/- 933555, corresponding to (hour=255, minute=255, second=255).
Definition at line 95 of file TimePeriod.h.
|
friend |
Return true if two TimePeriod objects are equal.
Optimized for small changes in the less signficant fields.
Definition at line 150 of file TimePeriod.h.