6 #ifndef ACE_TIME_ZONED_DATE_TIME_H
7 #define ACE_TIME_ZONED_DATE_TIME_H
10 #include "OffsetDateTime.h"
125 epochSeconds = unixSeconds
170 int16_t
year()
const {
return mOffsetDateTime.
year(); }
182 uint8_t
day()
const {
return mOffsetDateTime.
day(); }
188 uint8_t
hour()
const {
return mOffsetDateTime.
hour(); }
206 uint8_t
fold()
const {
return mOffsetDateTime.
fold(); }
236 return mOffsetDateTime;
319 return mOffsetDateTime.
compareTo(that.mOffsetDateTime);
327 void printTo(Print& printer)
const;
335 static const uint8_t kDateStringLength = 25;
344 OffsetDateTime mOffsetDateTime;
356 return a.mOffsetDateTime == b.mOffsetDateTime
357 && a.mTimeZone == b.mTimeZone;
static int64_t secondsToCurrentEpochFromUnixEpoch64()
Return the number of seconds from the Unix epoch (1970-01-01T00:00:00) to the current epoch.
Class that holds the date-time as the components (year, month, day, hour, minute, second) without reg...
static LocalDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint8_t fold=0)
Factory method using separated date and time components.
static const int64_t kInvalidUnixSeconds64
Sentinel unixSeconds64 which indicates an error.
static const int32_t kInvalidEpochSeconds
Sentinel epochSeconds which indicates an error.
The date (year, month, day), time (hour, minute, second) and fixed offset from UTC (timeOffset).
uint8_t day() const
Return the day of the month.
TimeOffset timeOffset() const
Return the UTC offset of the OffsetDateTime.
int64_t toUnixSeconds64() const
Return the 64-bit number of seconds from Unix epoch 1970-01-01 00:00:00 UTC.
bool isError() const
Return true if any component indicates an error condition.
const LocalDateTime & localDateTime() const
Return the LocalDateTime.
uint8_t hour() const
Return the hour.
uint8_t month() const
Return the month with January=1, December=12.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch taking into account the UTC offset.
static OffsetDateTime forError()
Factory method that returns an instance whose isError() is true.
uint8_t fold() const
Return the fold.
int8_t compareTo(const OffsetDateTime &that) const
Compare 'this' OffsetDateTime with 'that' OffsetDateTime, and return (<0, 0, >0) according to whether...
uint8_t minute() const
Return the minute.
int16_t year() const
Return the year.
static OffsetDateTime forDateString(const char *dateString)
Factory method.
uint8_t dayOfWeek() const
Return the day of the week, Monday=1, Sunday=7 (per ISO 8601).
int32_t toEpochDays() const
Return number of whole days since AceTime epoch taking into account the UTC offset.
int32_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
uint8_t second() const
Return the second.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC,...
Class that describes a time zone.
OffsetDateTime getOffsetDateTime(const LocalDateTime &ldt) const
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the current TimeZone.
static TimeZone forTimeOffset(TimeOffset stdOffset, TimeOffset dstOffset=TimeOffset())
Factory method to create from a UTC offset and an optional DST offset.
The date (year, month, day), time (hour, minute, second), and a timeZone object that supports the zon...
static ZonedDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, const TimeZone &timeZone, uint8_t fold=0)
Factory method using separated date, time, and time zone fields.
int8_t compareTo(const ZonedDateTime &that) const
Compare 'this' ZonedDateTime with 'that' ZonedDateTime, and return (<0, 0, >0) according to whether t...
const TimeZone & timeZone() const
Return the time zone of the ZonedDateTime.
uint8_t hour() const
Return the hour.
void fold(uint8_t fold)
Set the fold.
int32_t toEpochDays() const
Return number of whole days since AceTime epoch taking into account the time zone.
int16_t year() const
Return the year.
void printTo(Print &printer) const
Print ZonedDateTime to 'printer'.
uint8_t dayOfWeek() const
Return the day of the week using ISO 8601 numbering where Monday=1 and Sunday=7.
static ZonedDateTime forLocalDateTime(const LocalDateTime &ldt, const TimeZone &timeZone)
Factory method using LocalDateTime and time zone fields.
friend bool operator==(const ZonedDateTime &a, const ZonedDateTime &b)
Return true if two ZonedDateTime objects are equal in all components.
static ZonedDateTime forDateString(const __FlashStringHelper *dateString)
Factory method.
uint8_t fold() const
Return the fold.
ZonedDateTime convertToTimeZone(const TimeZone &timeZone) const
Create a ZonedDateTime in a different time zone (with the same epochSeconds).
bool isError() const
Return true if any component indicates an error condition.
void day(uint8_t day)
Set the day of the month.
void minute(uint8_t minute)
Set the minute.
int64_t toUnixSeconds64() const
Return the 64-bit number of seconds from Unix epoch 1970-01-01 00:00:00 UTC.
uint8_t day() const
Return the day of the month.
static ZonedDateTime forUnixSeconds64(int64_t unixSeconds, const TimeZone &timeZone)
Factory method to create a ZonedDateTime using the 64-bit number of seconds from Unix epoch.
void second(uint8_t second)
Set the second.
uint8_t second() const
Return the second.
static ZonedDateTime forError()
Return an instance whose isError() returns true.
static ZonedDateTime forEpochSeconds(acetime_t epochSeconds, const TimeZone &timeZone)
Factory method.
void year(int16_t year)
Set the year given the full year.
void hour(uint8_t hour)
Set the hour.
ZonedDateTime()
Default constructor.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch taking into account the time zone.
uint8_t minute() const
Return the minute.
void timeZone(const TimeZone &timeZone)
Set the time zone.
void normalize()
Normalize the ZonedDateTime after mutation.
void month(uint8_t month)
Set the month.
TimeOffset timeOffset() const
Return the offset zone of the OffsetDateTime.
int32_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
static ZonedDateTime forDateString(const char *dateString)
Factory method.
const LocalDateTime & localDateTime() const
Return the LocalDateTime of the components.
uint8_t month() const
Return the month with January=1, December=12.
const OffsetDateTime & offsetDateTime() const
Return the OffsetDateTime of the components.
int32_t acetime_t
Type for the number of seconds from epoch.