AceTime
1.7.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.
|
6 #ifndef ACE_TIME_LOCAL_TIME_H
7 #define ACE_TIME_LOCAL_TIME_H
10 #include "common/common.h"
61 uint16_t minutes = seconds / 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;
153 if (mHour < that.mHour)
return -1;
154 if (mHour > that.mHour)
return 1;
155 if (mMinute < that.mMinute)
return -1;
156 if (mMinute > that.mMinute)
return 1;
157 if (mSecond < that.mSecond)
return -1;
158 if (mSecond > that.mSecond)
return 1;
167 void printTo(Print& printer)
const;
177 static const uint8_t kTimeStringLength = 8;
180 static const uint8_t kInvalidValue = UINT8_MAX;
195 return a.mSecond == b.mSecond
196 && a.mMinute == b.mMinute
197 && a.mHour == b.mHour;
static LocalTime forTimeStringChainable(const char *&timeString)
Variant of forTimeString() that updates the pointer to the next unprocessed character.
void second(uint8_t second)
Set the second.
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
void minute(uint8_t month)
Set the minute.
void printTo(Print &printer) const
Print LocalTime to 'printer' in ISO 8601 format.
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.
uint8_t hour() const
Return the hour.
uint8_t second() const
Return the second.
acetime_t toSeconds() const
Return the number of seconds since midnight.
uint8_t minute() const
Return the minute.
static LocalTime forComponents(uint8_t hour, uint8_t minute, uint8_t second)
Factory method using separated date, time, and time zone fields.
int8_t compareTo(const LocalTime &that) const
Compare 'this' LocalTime with 'that' LocalTime, and return (<0, 0, >0) according to whether 'this' oc...
LocalTime()
Default constructor does nothing.
static LocalTime forTimeString(const char *timeString)
Factory method.
friend bool operator==(const LocalTime &a, const LocalTime &b)
Return true if two LocalTime objects are equal.
void hour(uint8_t hour)
Set the hour.
The time (hour, minute, second) fields representing the time without regards to the day or the time z...
static LocalTime forSeconds(acetime_t seconds)
Factory method.