AceTime
1.11.2
Date and time classes for Arduino that support timezones from the TZ Database.
|
6 #ifndef ACE_TIME_ZONED_DATE_TIME_H
7 #define ACE_TIME_ZONED_DATE_TIME_H
11 #include "OffsetDateTime.h"
158 int16_t
year()
const {
return mOffsetDateTime.
year(); }
184 uint8_t
day()
const {
return mOffsetDateTime.
day(); }
190 uint8_t
hour()
const {
return mOffsetDateTime.
hour(); }
208 uint8_t
fold()
const {
return mOffsetDateTime.
fold(); }
329 return mOffsetDateTime.
compareTo(that.mOffsetDateTime);
337 void printTo(Print& printer)
const;
345 static const uint8_t kDateStringLength = 25;
351 mOffsetDateTime(offsetDateTime),
354 OffsetDateTime mOffsetDateTime;
366 return a.mOffsetDateTime == b.mOffsetDateTime
367 && a.mTimeZone == b.mTimeZone;
uint8_t second() const
Return the second.
static OffsetDateTime forDateString(const char *dateString)
Factory method.
static const int32_t kInvalidEpochSeconds
Sentinel epochSeconds which indicates an error.
Class that holds the date-time as the components (year, month, day, hour, minute, second) without reg...
friend bool operator==(const ZonedDateTime &a, const ZonedDateTime &b)
Return true if two ZonedDateTime objects are equal in all components.
uint8_t fold() const
Return the fold.
int32_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z), taking into account the offse...
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch (2000-01-01 00:00:00Z), taking into account the offset zone.
uint8_t month() const
Return the month with January=1, December=12.
int64_t toUnixSeconds64() const
Return the 64-bit number of seconds from Unix epoch 1970-01-01 00:00:00Z.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC,...
int32_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z), taking into account the time ...
void timeZone(const TimeZone &timeZone)
Set the time zone.
const LocalDateTime & localDateTime() const
Return the LocalDateTime of the components.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
uint8_t hour() const
Return the hour.
static ZonedDateTime forEpochSeconds(acetime_t epochSeconds, const TimeZone &timeZone)
Factory method.
int8_t compareTo(const ZonedDateTime &that) const
Compare 'this' ZonedDateTime with 'that' ZonedDateTime, and return (<0, 0, >0) according to whether t...
void minute(uint8_t minute)
Set the minute.
uint8_t dayOfWeek() const
Return the day of the week, Monday=1, Sunday=7 (per ISO 8601).
int32_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
OffsetDateTime getOffsetDateTime(const LocalDateTime &ldt) const
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the current TimeZone.
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.
int64_t toUnixSeconds64() const
Return the 64-bit number of seconds from Unix epoch 1970-01-01 00:00:00Z.
static const int64_t kMinValidUnixSeconds64
Minimum 64-bit Unix seconds supported by acetime_t.
The date (year, month, day), time (hour, minute, second) and offset from UTC (timeOffset).
const TimeZone & timeZone() const
Return the time zone of the ZonedDateTime.
void second(uint8_t second)
Set the second.
static OffsetDateTime forError()
Factory method that returns an instance whose isError() is true.
int16_t year() const
Return the year.
uint8_t second() const
Return the second.
static ZonedDateTime forDateString(const char *dateString)
Factory method.
int32_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
uint8_t fold() const
Return the fold.
static const int32_t kInvalidUnixSeconds
Sentinel unixSeconds which indicates an error.
void printTo(Print &printer) const
Print ZonedDateTime to 'printer'.
int8_t compareTo(const OffsetDateTime &that) const
Compare 'this' OffsetDateTime with 'that' OffsetDateTime, and return (<0, 0, >0) according to whether...
uint8_t month() const
Return the month with January=1, December=12.
int32_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
void fold(uint8_t fold)
Set the fold.
static const int32_t kSecondsSinceUnixEpoch
Number of seconds from Unix epoch (1970-01-01 00:00:00Z) to the AceTime epoch (2000-01-01 00:00:00Z).
bool isError() const
Return true if any component indicates an error condition.
uint8_t minute() const
Return the minute.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch (2000-01-01 00:00:00Z), taking into account the time zone.
TimeOffset timeOffset() const
Return the offset zone of the OffsetDateTime.
The date (year, month, day), time (hour, minute, second), and a timeZone representing an instant in t...
uint8_t day() const
Return the day of the month.
TimeOffset timeOffset() const
Return the offset zone of the OffsetDateTime.
uint8_t minute() const
Return the minute.
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, uint8_t fold=0)
Factory method using separated date and time components.
void day(uint8_t day)
Set the day of the month.
void month(uint8_t month)
Set the month.
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.
void yearTiny(int8_t yearTiny)
Set the single-byte year offset from year 2000.
bool isError() const
Return true if any component indicates an error condition.
uint8_t hour() const
Return the hour.
static const int64_t kInvalidUnixSeconds64
Sentinel 64-bit unixSeconds which indicates an error.
Class that describes a time zone.
ZonedDateTime convertToTimeZone(const TimeZone &timeZone) const
Create a ZonedDateTime in a different time zone (with the same epochSeconds).
static ZonedDateTime forUnixSeconds(int32_t unixSeconds, const TimeZone &timeZone)
Factory method to create a ZonedDateTime using the number of seconds from Unix epoch.
static TimeZone forTimeOffset(TimeOffset stdOffset, TimeOffset dstOffset=TimeOffset())
Factory method to create from a UTC offset and an optional DST offset.
uint8_t dayOfWeek() const
Return the day of the week using ISO 8601 numbering where Monday=1 and Sunday=7.
const LocalDateTime & localDateTime() const
Return the LocalDateTime.
void normalize()
Normalize the ZonedDateTime after mutation.
uint8_t day() const
Return the day of the month.
void hour(uint8_t hour)
Set the hour.
void year(int16_t year)
Set the year given the full year.
ZonedDateTime()
Default constructor.
int16_t year() const
Return the year.
static const int64_t kMaxValidUnixSeconds64
Maximum 64-bit Unix seconds supported by acetime_t.
static ZonedDateTime forDateString(const __FlashStringHelper *dateString)
Factory method.
int32_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
int8_t yearTiny() const
Return the single-byte year offset from year 2000.