AceTime 3.0.0 Date and time classes for Arduino that support timezones from the TZ Database.

Static Public Member Functions | Static Public Attributes | List of all members
ace_time::EpochConverterHinnant Class Reference

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).

## Detailed Description

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.

## Member Function Documentation

## ◆ fromEpochDays()

static void ace_time::EpochConverterHinnant::fromEpochDays | ( | int32_t | epochDays,
|  | int16_t & | year,
|  | uint8_t & | month,
|  | uint8_t & | day
| ) |  |
| inline static

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.

Parameters

  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.

## ◆ toDaysUntilMonthPrime()

static uint16_t ace_time::EpochConverterHinnant::toDaysUntilMonthPrime | ( | uint8_t | monthPrime | ) |
| inline static

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.

## ◆ toEpochDays()

static int32_t ace_time::EpochConverterHinnant::toEpochDays | ( | int16_t | year,
|  | uint8_t | month,
|  | uint8_t | day
| ) |  |
| inline static

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).

Parameters

  year,[1,9999] |
  month | month integer, [1,12]
  day | day of month integer, [1,31]

Definition at line 47 of file EpochConverterHinnant.h.

## Member Data Documentation

## ◆ kInternalEpochYear

const int16_t ace_time::EpochConverterHinnant::kInternalEpochYear = 2000
| 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.

The documentation for this class was generated from the following file:

- /home/brian/src/AceTimeSuite/libraries/AceTimeLib/src/ace_time/EpochConverterHinnant.h