6 #ifndef ACE_TIME_LOCAL_TIME_H 7 #define ACE_TIME_LOCAL_TIME_H 10 #include "common/common.h" 57 if (seconds == kInvalidSeconds) {
58 second = minute = hour = kInvalidValue;
60 second = seconds % 60;
61 uint16_t minutes = seconds / 60;
62 minute = minutes % 60;
94 return LocalTime(kInvalidValue, kInvalidValue, kInvalidValue);
107 if (mSecond >= 60)
return true;
108 if (mMinute >= 60)
return true;
110 return mSecond != 0 || mMinute != 0;
116 uint8_t
hour()
const {
return mHour; }
122 uint8_t
minute()
const {
return mMinute; }
125 void minute(uint8_t month) { mMinute = month; }
128 uint8_t
second()
const {
return mSecond; }
141 return ((mHour * (int16_t) 60) + mMinute)
142 * (int32_t) 60 + mSecond;
152 if (mHour < that.mHour)
return -1;
153 if (mHour > that.mHour)
return 1;
154 if (mMinute < that.mMinute)
return -1;
155 if (mMinute > that.mMinute)
return 1;
156 if (mSecond < that.mSecond)
return -1;
157 if (mSecond > that.mSecond)
return 1;
166 void printTo(Print& printer)
const;
176 static const uint8_t kTimeStringLength = 8;
179 static const uint8_t kInvalidValue = UINT8_MAX;
194 return a.mSecond == b.mSecond
195 && a.mMinute == b.mMinute
196 && 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.