1 #ifndef ACE_TIME_LOCAL_DATE_TIME_H 2 #define ACE_TIME_LOCAL_DATE_TIME_H 9 class __FlashStringHelper;
43 acetime_t days = (epochSeconds < 0)
44 ? (epochSeconds + 1) / 86400 - 1
45 : epochSeconds / 86400;
49 acetime_t seconds = epochSeconds - 86400 * days;
96 char buffer[kDateTimeStringLength + 2];
97 strncpy_P(buffer, (
const char*) dateString,
sizeof(buffer));
98 buffer[kDateTimeStringLength + 1] = 0;
101 size_t len = strlen(buffer);
102 if (len > kDateTimeStringLength) {
141 uint8_t
day()
const {
return mLocalDate.
day(); }
177 void printTo(Print& printer)
const;
200 acetime_t seconds = mLocalTime.
toSeconds();
201 return days * 86400 + seconds;
223 if (thisSeconds < thatSeconds)
return -1;
224 if (thisSeconds > thatSeconds)
return 1;
239 static const uint8_t kDateTimeStringLength = 19;
248 static LocalDateTime forDateStringChainable(
const char*& dateString);
263 mLocalTime(hour, minute, second) {}
270 const LocalDate& getLocalDate()
const {
return mLocalDate; }
282 return a.mLocalDate == b.mLocalDate
283 && a.mLocalTime == b.mLocalTime;
static const acetime_t kSecondsSinceUnixEpoch
Number of seconds from Unix epoch (1970-01-01 00:00:00Z) to the AceTime epoch (2000-01-01 00:00:00Z)...
static LocalDate forEpochDays(acetime_t epochDays)
Factory method using the number of days since AceTime epoch of 2000-01-01.
uint8_t hour() const
Return the hour.
int8_t compareTo(const LocalDateTime &that) const
Compare this LocalDateTime with another LocalDateTime, and return (<0, 0, >0) according to whether th...
static const acetime_t kDaysSinceUnixEpoch
Number of days from Unix epoch (1970-01-01 00:00:00Z) to the AceTime epoch (2000-01-01 00:00:00Z)...
uint8_t month() const
Return the month with January=1, December=12.
static LocalDateTime forDateString(const __FlashStringHelper *dateString)
Factory method.
static LocalDate forError()
Factory method that returns a LocalDate which represents an error condition.
static const acetime_t kInvalidEpochDays
Sentinel epochDays which indicates an error.
static const acetime_t kInvalidEpochSeconds
Sentinel epochSeconds which indicates an error.
The time (hour, minute, second) fields representing the time without regards to the day or the time z...
uint8_t month() const
Return the month with January=1, December=12.
uint8_t second() const
Return the second.
uint8_t minute() const
Return the minute.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
bool isError() const
Return true if any component indicates an error condition.
An implementation of ZoneSpecifier that works for all zones defined by the TZ Database (with some zon...
static LocalDateTime forEpochSeconds(acetime_t epochSeconds)
Factory method.
acetime_t toSeconds() const
Return the number of seconds since midnight.
bool isError() const
Return true if any component indicates an error condition.
const LocalDate & localDate() const
Return the LocalDate.
void minute(uint8_t minute)
Set the minute.
void hour(uint8_t hour)
Set the hour.
static LocalDateTime forDateString(const char *dateString)
Factory method.
void yearTiny(int8_t yearTiny)
Set the single-byte year offset from year 2000.
static LocalDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
Factory method using separated date, time.
int16_t year() const
Return the year.
void printTo(Print &printer) const
Print LocalDateTime to 'printer' in ISO 8601 format.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch (2000-01-01 00:00:00Z).
uint8_t day() const
Return the day of the month.
int16_t year() const
Return the full year instead of just the last 2 digits.
acetime_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
uint8_t day() const
Return the day of the month.
void year(int16_t year)
Set the year.
The date (year, month, day) and time (hour, minute, second) fields representing the time with an offs...
acetime_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
acetime_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z).
static LocalDateTime forUnixSeconds(acetime_t unixSeconds)
Factory method that takes the number of seconds since Unix Epoch of 1970-01-01.
static LocalDateTime forError()
Factory method that returns an instance where isError() returns true.
static LocalTime forError()
Factory method that returns an instance which indicates an error condition.
The date (year, month, day) representing the date without regards to time zone.
friend bool operator==(const LocalDateTime &a, const LocalDateTime &b)
Return true if two LocalDateTime objects are equal in all components.
uint8_t hour() const
Return the hour.
const LocalTime & localTime() const
Return the LocalTime.
static const int16_t kEpochYear
Base year of epoch.
void month(uint8_t month)
Set the month.
uint8_t dayOfWeek() const
Calculate the day of week given the (year, month, day).
uint8_t second() const
Return the second.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
LocalDateTime()
Constructor.
bool isError() const
Return true if any component is outside the normal time range of 00:00:00 to 23:59:59.
uint8_t minute() const
Return the minute.
acetime_t toEpochDays() const
Return number of days since AceTime epoch (2000-01-01 00:00:00Z).
static LocalTime forSeconds(acetime_t seconds)
Factory method.
An implementation of ZoneSpecifier that supports a subset of the zones containing in the TZ Database...
void second(uint8_t second)
Set the second.
uint8_t dayOfWeek() const
Return the day of the week, Monday=1, Sunday=7 (per ISO 8601).
void day(uint8_t day)
Set the day of the month.