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 <EpochConverterJulian.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 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). | |
static const int32_t | kDaysToInternalEpochFromJulianEpoch |
Number of days from the modified proleptic Julian calendar epoch (4713 BC 01-01, modified to start at 00:00:00 instead of 12:00:00) to the internal epoch (2000-01-01). More... | |
Utility class that converts AceTime epoch days to (year, month, day) in the Gregorian calendar and vise versa.
Uses the algorithm described in https://en.wikipedia.org/wiki/Julian_day which converts into Julian days as an intermediate step.
Definition at line 19 of file EpochConverterJulian.h.
|
inlinestatic |
Extract the (year, month, day) fields from AceTime epochDays.
See https://en.wikipedia.org/wiki/Julian_day for formula.
No input validation is performed. The behavior is undefined if the parameters are outside their expected range.
Definition at line 86 of file EpochConverterJulian.h.
|
inlinestatic |
Convert (year, month, day) in the Gregorian calendar to days since the internal epoch (2000-01-01).
The (year, month, day) is converted into Julian days, then converted to epoch days since AceTime Epoch. The Julian day normally start at 12:00:00, but we use a modified Julian day number starting at 00:00:00 to make it easier to convert to the Gregorian calendar day.
* JDN = (1461 x (Y + 4800 + (M - 14)/12))/4 * + (367 x (M - 2 - 12 x ((M - 14)/12)))/12 * - (3 x ((Y + 4900 + (M - 14)/12)/100))/4 * + D - 32075 * JDN2000 = JDN - 2451545 *
It looks like the formula needs to be done using signed integers because it depends on the modulo operation (%) to truncate towards 0 for negative numbers.
No input validation is performed. The behavior is undefined if the parameters are outside their expected range.
year | year [1,9999] |
month | month integer [1, 12] |
day | day of month integer[1, 31] |
Definition at line 70 of file EpochConverterJulian.h.
|
static |
Number of days from the modified proleptic Julian calendar epoch (4713 BC 01-01, modified to start at 00:00:00 instead of 12:00:00) to the internal epoch (2000-01-01).
There are 1721060 days from the modified Julian epoch to 0000-01-01 of the proleptic Gregorian calendar. We then need to add 2000 years (5 x 400 years) to get to 2000-01-01.
Definition at line 40 of file EpochConverterJulian.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 25 of file EpochConverterJulian.h.