1 #ifndef ACE_TIME_DATE_TIME_H 2 #define ACE_TIME_DATE_TIME_H 5 #include "common/flash.h" 6 #include "OffsetDateTime.h" 7 #include "ExtendedZoneSpecifier.h" 55 year, month, day, hour, minute, second);
76 if (epochSeconds == kInvalidEpochSeconds)
return forError();
80 epochSeconds, timeOffset);
138 int16_t
year()
const {
return mOffsetDateTime.
year(); }
141 void year(int16_t year) { mOffsetDateTime.
year(year); }
156 uint8_t
day()
const {
return mOffsetDateTime.
day(); }
159 void day(uint8_t day) { mOffsetDateTime.
day(day); }
162 uint8_t
hour()
const {
return mOffsetDateTime.
hour(); }
165 void hour(uint8_t hour) { mOffsetDateTime.
hour(hour); }
210 void printTo(Print& printer)
const;
257 return mOffsetDateTime.
compareTo(that.mOffsetDateTime);
266 static const uint8_t kDateStringLength = 25;
273 mOffsetDateTime(offsetDateTime),
288 return a.mOffsetDateTime == b.mOffsetDateTime
289 && a.mTimeZone == b.mTimeZone;
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)...
TimeOffset timeOffset() const
Return the offset zone of the OffsetDateTime.
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)...
void yearTiny(int8_t yearTiny)
Set the single-byte year offset from year 2000.
acetime_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
static const acetime_t kInvalidEpochDays
Sentinel epochDays which indicates an error.
uint8_t dayOfWeek() const
Return the day of the week, Monday=1, Sunday=7 (per ISO 8601).
static ZonedDateTime forEpochSeconds(acetime_t epochSeconds, const TimeZone &timeZone=TimeZone())
Factory method.
static const acetime_t kInvalidEpochSeconds
Sentinel epochSeconds which indicates an error.
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
const TimeZone & timeZone() const
Return the time zone of the ZonedDateTime.
void printTo(Print &printer) const
Print ZonedDateTime to 'printer'.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch (2000-01-01 00:00:00Z), taking into account the time zone...
TimeOffset getUtcOffset(acetime_t epochSeconds) const
Return the total UTC offset at epochSeconds, including DST offset.
static TimeZone forTimeOffset(TimeOffset offset=TimeOffset())
Factory method to create from a fixed UTC offset.
void second(uint8_t second)
Set the second.
void hour(uint8_t hour)
Set the hour.
uint8_t dayOfWeek() const
Return the day of the week using ISO 8601 numbering where Monday=1 and Sunday=7.
void day(uint8_t day)
Set the day of the month.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch (2000-01-01 00:00:00Z), taking into account the offset zone...
TimeOffset getUtcOffsetForDateTime(const LocalDateTime &ldt) const
Return the best guess of the UTC offset at the given LocalDateTime for the current TimeZone...
acetime_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
static ZonedDateTime forError()
Return an instance whose isError() returns true.
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.
uint8_t month() const
Return the month with January=1, December=12.
uint8_t hour() const
Return the hour.
acetime_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z), taking into account the offse...
static ZonedDateTime forDateString(const char *dateString)
Factory method.
void year(int16_t year)
Set the year given the full year.
ZonedDateTime convertToTimeZone(const TimeZone &timeZone) const
Create a ZonedDateTime in a different time zone (with the same epochSeconds).
uint8_t hour() const
Return the hour.
int8_t compareTo(const OffsetDateTime &that) const
Compare this OffsetDateTime with another OffsetDateTime, and return (<0, 0, >0) according to whether ...
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
friend bool operator!=(const ZonedDateTime &a, const ZonedDateTime &b)
Return true if two ZonedDateTime objects are not equal.
int8_t compareTo(const ZonedDateTime &that) const
Compare this ZonedDateTime with another ZonedDateTime, and return (<0, 0, >0) according to whether th...
uint8_t day() const
Return the day of the month.
The date (year, month, day) and time (hour, minute, second) fields representing the time with an offs...
bool isError() const
Return true if any component indicates an error condition.
static ZonedDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, const TimeZone &timeZone=TimeZone())
Factory method using separated date, time, and time zone fields.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC...
int16_t year() const
Return the year.
static OffsetDateTime forEpochSeconds(acetime_t epochSeconds, TimeOffset timeOffset=TimeOffset())
Factory method.
uint8_t day() const
Return the day of the month.
TimeOffset timeOffset() const
Return the offset zone of the OffsetDateTime.
int16_t year() const
Return the year.
Class that describes a time zone.
The date (year, month, day) and time (hour, minute, second) fields representing an instant in time...
uint8_t second() const
Return the second.
void minute(uint8_t minute)
Set the minute.
static ZonedDateTime forDateString(const __FlashStringHelper *dateString)
Factory method.
acetime_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
friend bool operator==(const ZonedDateTime &a, const ZonedDateTime &b)
Return true if two ZonedDateTime objects are equal in all components.
uint8_t minute() const
Return the minute.
void timeZone(const TimeZone &timeZone)
Set the time zone.
bool isError() const
Return true if any component indicates an error condition.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
ZonedDateTime()
Default constructor.
static ZonedDateTime forUnixSeconds(acetime_t unixSeconds, const TimeZone &timeZone=TimeZone())
Factory method to create a ZonedDateTime using the number of seconds from Unix epoch.
uint8_t month() const
Return the month with January=1, December=12.
void month(uint8_t month)
Set the month.
uint8_t second() const
Return the second.
static OffsetDateTime forError()
Factory method that returns an instance whose isError() is true.
uint8_t minute() const
Return the minute.
acetime_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z), taking into account the time ...
static OffsetDateTime forDateString(const char *dateString)
Factory method.