AceTime
1.7.1
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.
|
6 #ifndef ACE_TIME_TIME_PERIOD_H
7 #define ACE_TIME_TIME_PERIOD_H
66 mSecond = mMinute = mHour = 255;
77 mSecond = seconds % 60;
79 mMinute = seconds % 60;
85 uint8_t
hour()
const {
return mHour; }
91 uint8_t
minute()
const {
return mMinute; }
97 uint8_t
second()
const {
return mSecond; }
103 int8_t
sign()
const {
return mSign; }
120 int32_t seconds = ((mHour * (int16_t) 60) + mMinute) * (int32_t) 60
122 return (mSign > 0) ? seconds : -seconds;
127 return mSign == 0 || mSecond == 255 || mMinute == 255;
138 if (thisSeconds < thatSeconds) {
140 }
else if (thisSeconds > thatSeconds) {
155 void printTo(Print& printer)
const;
183 return a.mSecond == b.mSecond
184 && a.mMinute == b.mMinute
185 && a.mHour == b.mHour
186 && a.mSign == b.mSign;
void second(uint8_t second)
Set the second.
Represents a period of time relative to some known point in time, potentially represented by a DateTi...
uint8_t second() const
Return the second.
uint8_t hour() const
Return the hour.
static TimePeriod forError()
Factory method that creates a TimePeriod representing an error so that isError() returns true.
int8_t sign() const
Return the sign bit.
int32_t toSeconds() const
Convert to number of seconds.
void hour(uint8_t hour)
Set the hour.
TimePeriod(uint8_t hour, uint8_t minute, uint8_t second, int8_t sign=1)
Constructor.
void minute(uint8_t minute)
Set the minute.
static const int32_t kInvalidPeriodSeconds
An invalid time period seconds.
friend bool operator==(const TimePeriod &a, const TimePeriod &b)
Return true if two TimePeriod objects are equal.
TimePeriod(int32_t seconds=0)
Constructor from number of seconds.
int8_t compareTo(const TimePeriod &that) const
Compare 'this' TimePeriod with 'that' TimePeriod and return (<0, 0, >0) according to (this<that,...
void sign(int8_t sign)
Set the sign bit.
void printTo(Print &printer) const
Print to given printer.
static const int32_t kMaxPeriodSeconds
The largest period that can be represented by this class, in seconds.
bool isError() const
Return true if this represents an error.
uint8_t minute() const
Return the minute.