6 #ifndef ACE_TIME_LOCAL_TIME_H
7 #define ACE_TIME_LOCAL_TIME_H
63 uint16_t minutes = seconds / 60;
96 return LocalTime(kInvalidValue, kInvalidValue, kInvalidValue);
109 if (mSecond >= 60)
return true;
110 if (mMinute >= 60)
return true;
112 return mSecond != 0 || mMinute != 0;
118 uint8_t
hour()
const {
return mHour; }
124 uint8_t
minute()
const {
return mMinute; }
130 uint8_t
second()
const {
return mSecond; }
136 uint8_t
fold()
const {
return mFold; }
149 return ((mHour * (int16_t) 60) + mMinute)
150 * (int32_t) 60 + mSecond;
163 if (mHour < that.mHour)
return -1;
164 if (mHour > that.mHour)
return 1;
165 if (mMinute < that.mMinute)
return -1;
166 if (mMinute > that.mMinute)
return 1;
167 if (mSecond < that.mSecond)
return -1;
168 if (mSecond > that.mSecond)
return 1;
177 void printTo(Print& printer)
const;
187 static const uint8_t kTimeStringLength = 8;
190 static const uint8_t kInvalidValue = UINT8_MAX;
221 return a.mSecond == b.mSecond
222 && a.mMinute == b.mMinute
223 && a.mHour == b.mHour;
The time (hour, minute, second) fields representing the time without regards to the day or the time z...
static const int32_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
static LocalTime forComponents(uint8_t hour, uint8_t minute, uint8_t second, uint8_t fold=0)
Factory method using separated date, time, and time zone fields.
uint8_t fold() const
Return the fold.
friend bool operator==(const LocalTime &a, const LocalTime &b)
Return true if two LocalTime objects are equal.
acetime_t toSeconds() const
Return the number of seconds since midnight.
static LocalTime forTimeStringChainable(const char *&timeString)
Variant of forTimeString() that updates the pointer to the next unprocessed character.
void minute(uint8_t minute)
Set the minute.
void hour(uint8_t hour)
Set the hour.
static LocalTime forError()
Factory method that returns an instance which indicates an error condition.
static LocalTime forTimeString(const char *timeString)
Factory method.
void printTo(Print &printer) const
Print LocalTime to 'printer' in ISO 8601 format.
LocalTime()
Default constructor does nothing.
uint8_t hour() const
Return the hour.
void second(uint8_t second)
Set the second.
uint8_t minute() const
Return the minute.
static LocalTime forSeconds(acetime_t seconds, uint8_t fold=0)
Factory method.
uint8_t second() const
Return the second.
bool isError() const
Return true if any component is outside the normal time range of 00:00:00 to 23:59:59.
void fold(uint8_t fold)
Set the fold.
int8_t compareTo(const LocalTime &that) const
Compare 'this' LocalTime with 'that' LocalTime, and return (<0, 0, >0) according to whether 'this' oc...
Identifiers used by implementation code which need to be publically exported.
int32_t acetime_t
Type for the number of seconds from epoch.