AceTime
1.9.0
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"
138 int16_t
year()
const {
return mOffsetDateTime.
year(); }
164 uint8_t
day()
const {
return mOffsetDateTime.
day(); }
170 uint8_t
hour()
const {
return mOffsetDateTime.
hour(); }
293 return mOffsetDateTime.
compareTo(that.mOffsetDateTime);
301 void printTo(Print& printer)
const;
309 static const uint8_t kDateStringLength = 25;
315 mOffsetDateTime(offsetDateTime),
318 OffsetDateTime mOffsetDateTime;
330 return a.mOffsetDateTime == b.mOffsetDateTime
331 && a.mTimeZone == b.mTimeZone;
uint8_t second() const
Return the second.
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).
acetime_t toUnixSeconds() const
Return the number of seconds from Unix epoch 1970-01-01 00:00:00Z.
static OffsetDateTime forDateString(const char *dateString)
Factory method.
static const acetime_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.
static const acetime_t kInvalidEpochDays
Sentinel epochDays which indicates an error.
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.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC,...
void timeZone(const TimeZone &timeZone)
Set the time zone.
const LocalDateTime & localDateTime() const
Return the LocalDateTime of the components.
static OffsetDateTime forEpochSeconds(acetime_t epochSeconds, TimeOffset timeOffset)
Factory method.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.
uint8_t hour() const
Return the hour.
TimeOffset getUtcOffset(acetime_t epochSeconds) const
Return the total UTC offset at epochSeconds, including DST offset.
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).
acetime_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 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 and time components.
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.
static ZonedDateTime forUnixSeconds(acetime_t unixSeconds, const TimeZone &timeZone)
Factory method to create a ZonedDateTime using the number of seconds from Unix epoch.
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...
static ZonedDateTime forComponents(int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, const TimeZone &timeZone)
Factory method using separated date, time, and time zone fields.
uint8_t month() const
Return the month with January=1, December=12.
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.
acetime_t toUnixDays() const
Return the number of days since Unix epoch (1970-01-01 00:00:00).
void day(uint8_t day)
Set the day of the month.
void month(uint8_t month)
Set the month.
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.
Class that describes a time zone.
acetime_t toEpochDays() const
Return number of whole days since AceTime epoch (2000-01-01 00:00:00Z), taking into account the time ...
ZonedDateTime convertToTimeZone(const TimeZone &timeZone) const
Create a ZonedDateTime in a different time zone (with the same epochSeconds).
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.
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).
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.
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 __FlashStringHelper *dateString)
Factory method.
int8_t yearTiny() const
Return the single-byte year offset from year 2000.