AceTime
3.0.0
Date and time classes for Arduino that support timezones from the TZ Database.
|
Utility class that converts AceTime epoch days to (year, month, day) in the Gregorian calendar and vise versa. More...
#include <EpochConverterHinnant.h>
Static Public Member Functions | |
static int32_t | toEpochDays (int16_t year, uint8_t month, uint8_t day) |
Convert (year, month, day) in the Gregorian calendar to days since the internal epoch (2000-01-01). More... | |
static void | fromEpochDays (int32_t epochDays, int16_t &year, uint8_t &month, uint8_t &day) |
Extract the (year, month, day) fields from AceTime epochDays. More... | |
static uint16_t | toDaysUntilMonthPrime (uint8_t monthPrime) |
Return the number days before the given monthPrime. More... | |
Static Public Attributes | |
static const int16_t | kInternalEpochYear = 2000 |
Epoch year used by this epoch converter. More... | |
static const int32_t | kDaysToInternalEpochFromUnixEpoch = 10957 |
Number of days from Unix epoch (1970-01-01 00:00:00 UTC) to the internal epoch (2000-01-01 00:00:00 UTC). | |
Utility class that converts AceTime epoch days to (year, month, day) in the Gregorian calendar and vise versa.
Uses the algorithm described in https://howardhinnant.github.io/date_algorithms.html.
Definition at line 18 of file EpochConverterHinnant.h.
|
inlinestatic |
Extract the (year, month, day) fields from AceTime epochDays.
No input validation is performed. The behavior is undefined if the parameters are outside their expected range.
epochDays | number of days from the internal epoch of 2000-01-01 |
year | year [1,9999] |
month | month integer [1, 12] |
day | day of month integer[1, 31] |
Definition at line 75 of file EpochConverterHinnant.h.
|
inlinestatic |
Return the number days before the given monthPrime.
This uses the original formula from Hinnant's paper.
Definition at line 99 of file EpochConverterHinnant.h.
|
inlinestatic |
Convert (year, month, day) in the Gregorian calendar to days since the internal epoch (2000-01-01).
The year
is restricted to be greater than or equal to 0001, which allows the internal 400-year era to start on 0000-03-01 with era=0, and we don't have to worry about negative eras.
No input validation is performed. The behavior is undefined if the parameters are outside their expected range. The algorithm will likely work for dates between 0000-03-01 and 32767-12-31 (inclusive), but has been tested only for dates between 0001-01-01 and 9999-12-31 (inclusive).
year,[1,9999] | |
month | month integer, [1,12] |
day | day of month integer, [1,31] |
Definition at line 47 of file EpochConverterHinnant.h.
|
static |
Epoch year used by this epoch converter.
Must be a multiple of 400. Other parts of the AceTime library will probably use a different epoch year.
Definition at line 24 of file EpochConverterHinnant.h.