6 #ifndef ACE_TIME_OFFSET_DATE_TIME_H
7 #define ACE_TIME_OFFSET_DATE_TIME_H
10 #include "TimeOffset.h"
11 #include "LocalDateTime.h"
156 int16_t
year()
const {
return mLocalDateTime.
year(); }
168 uint8_t
day()
const {
return mLocalDateTime.
day(); }
174 uint8_t
hour()
const {
return mLocalDateTime.
hour(); }
192 uint8_t
fold()
const {
return mLocalDateTime.
fold(); }
265 return epochSeconds - mTimeOffset.
toSeconds();
299 if (thisSeconds < thatSeconds)
return -1;
300 if (thisSeconds > thatSeconds)
return 1;
309 void printTo(Print& printer)
const;
319 static const uint8_t kDateStringLength = 25;
326 LocalDateTime mLocalDateTime;
327 TimeOffset mTimeOffset;
336 return a.mLocalDateTime == b.mLocalDateTime
337 && a.mTimeOffset == b.mTimeOffset;
static int32_t daysToCurrentEpochFromUnixEpoch()
Return the number of days 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...
int64_t toUnixSeconds64() const
Return 64-bit seconds from Unix epoch 1970-01-01 00:00:00 UTC, after assuming that the date and time ...
static LocalDateTime forEpochSeconds(acetime_t epochSeconds, uint8_t fold=0)
Factory method.
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.
uint8_t day() const
Return the day of the month.
const LocalDate & localDate() const
Return the LocalDate.
bool isError() const
Return true if any component indicates an error condition.
static LocalDateTime forUnixSeconds64(int64_t unixSeconds, uint8_t fold=0)
Factory method that takes the 64-bit number of seconds since Unix Epoch of 1970-01-01.
static LocalDateTime forError()
Factory method that returns an instance where isError() returns true.
uint8_t month() const
Return the month with January=1, December=12.
uint8_t fold() const
Return the fold.
uint8_t second() const
Return the second.
uint8_t minute() const
Return the minute.
const LocalTime & localTime() const
Return the LocalTime.
uint8_t hour() const
Return the hour.
uint8_t dayOfWeek() const
Return the day of the week, Monday=1, Sunday=7 (per ISO 8601).
acetime_t toEpochSeconds() const
Return seconds since the current AceTime epoch defined by Epoch::currentEpochYear().
int16_t year() const
Return the year.
The date (year, month, day) representing the date without regards to time zone.
static const int32_t kInvalidEpochDays
Sentinel epochDays which indicates an error.
static const int64_t kInvalidUnixSeconds64
Sentinel unixSeconds64 which indicates an error.
static const int32_t kInvalidEpochSeconds
Sentinel epochSeconds which indicates an error.
int32_t toEpochDays() const
Return number of days since the current epoch year sCurrentEpochYear.
The time (hour, minute, second) fields representing the time without regards to the day or the time z...
acetime_t toSeconds() const
Return the number of seconds since midnight.
The date (year, month, day), time (hour, minute, second) and fixed offset from UTC (timeOffset).
static OffsetDateTime forUnixSeconds64(int64_t unixSeconds, TimeOffset timeOffset, int8_t fold=0)
Factory method that takes the number of seconds (64-bit) since Unix Epoch of 1970-01-01.
const LocalTime & localTime() const
Return the LocalTime.
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.
static OffsetDateTime forDateStringChainable(const char *&dateString)
Variant of forDateString() that updates the pointer to the next unprocessed character.
void month(uint8_t month)
Set the month.
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.
void timeOffset(TimeOffset timeOffset)
Set the UTC offset.
OffsetDateTime()
Constructor.
uint8_t month() const
Return the month with January=1, December=12.
void printTo(Print &printer) const
Print OffsetDateTime to 'printer' in ISO 8601 format.
void minute(uint8_t minute)
Set the minute.
static OffsetDateTime forLocalDateTimeAndOffset(const LocalDateTime &localDateTime, TimeOffset timeOffset)
Factory method from LocalDateTime and TimeOffset.
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...
void hour(uint8_t hour)
Set the hour.
uint8_t minute() const
Return the minute.
OffsetDateTime convertToTimeOffset(TimeOffset timeOffset) const
Create a OffsetDateTime in a different UTC offset code (with the same epochSeconds).
int16_t year() const
Return the year.
void day(uint8_t day)
Set the day of the month.
const LocalDate & localDate() const
Return the LocalDate.
friend bool operator==(const OffsetDateTime &a, const OffsetDateTime &b)
Return true if two OffsetDateTime objects are equal in all components.
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).
static OffsetDateTime forEpochSeconds(acetime_t epochSeconds, TimeOffset timeOffset, uint8_t fold=0)
Factory method.
void year(int16_t year)
Set the year.
void second(uint8_t second)
Set the second.
void fold(uint8_t fold)
Set the fold.
uint8_t second() const
Return the second.
static OffsetDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, TimeOffset timeOffset, uint8_t fold=0)
Factory method using separated date, time, and UTC offset fields.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC,...
static TimeOffset forError()
Return an error indicator.
int32_t toSeconds() const
Return the time offset as seconds.
bool isError() const
Return true if this TimeOffset represents an error.
int32_t acetime_t
Type for the number of seconds from epoch.