1 #ifndef ACE_TIME_LOCAL_TIME_H 2 #define ACE_TIME_LOCAL_TIME_H 5 #include "common/common.h" 51 if (seconds == kInvalidSeconds) {
52 second = minute = hour = kInvalidValue;
54 second = seconds % 60;
55 uint16_t minutes = seconds / 60;
56 minute = minutes % 60;
88 return LocalTime(kInvalidValue, kInvalidValue, kInvalidValue);
101 if (mSecond >= 60)
return true;
102 if (mMinute >= 60)
return true;
104 return mSecond != 0 || mMinute != 0;
110 uint8_t
hour()
const {
return mHour; }
116 uint8_t
minute()
const {
return mMinute; }
119 void minute(uint8_t month) { mMinute = month; }
122 uint8_t
second()
const {
return mSecond; }
135 return ((mHour * (int16_t) 60) + mMinute)
136 * (int32_t) 60 + mSecond;
146 if (mHour < that.mHour)
return -1;
147 if (mHour > that.mHour)
return 1;
148 if (mMinute < that.mMinute)
return -1;
149 if (mMinute > that.mMinute)
return 1;
150 if (mSecond < that.mSecond)
return -1;
151 if (mSecond > that.mSecond)
return 1;
160 void printTo(Print& printer)
const;
170 static const uint8_t kTimeStringLength = 8;
173 static const uint8_t kInvalidValue = UINT8_MAX;
188 return a.mSecond == b.mSecond
189 && a.mMinute == b.mMinute
190 && a.mHour == b.mHour;
acetime_t toSeconds() const
Return the number of seconds since midnight.
void printTo(Print &printer) const
Print LocalTime to 'printer' in ISO 8601 format.
void second(uint8_t second)
Set the second.
void minute(uint8_t month)
Set the minute.
void hour(uint8_t hour)
Set the hour.
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
The time (hour, minute, second) fields representing the time without regards to the day or the time z...
static LocalTime forTimeStringChainable(const char *&timeString)
Variant of forTimeString() that updates the pointer to the next unprocessed character.
int8_t compareTo(const LocalTime &that) const
Compare this LocalTime with that LocalTime, and return (<0, 0, >0) according to whether (this<that...
bool isError() const
Return true if any component is outside the normal time range of 00:00:00 to 23:59:59.
static LocalTime forError()
Factory method that returns an instance which indicates an error condition.
static LocalTime forComponents(uint8_t hour, uint8_t minute, uint8_t second)
Factory method using separated date, time, and time zone fields.
uint8_t hour() const
Return the hour.
static LocalTime forTimeString(const char *timeString)
Factory method.
uint8_t minute() const
Return the minute.
uint8_t second() const
Return the second.
LocalTime()
Default constructor does nothing.
friend bool operator==(const LocalTime &a, const LocalTime &b)
Return true if two LocalTime objects are equal.
static LocalTime forSeconds(acetime_t seconds)
Factory method.