AceTime  2.2.0
Date and time classes for Arduino that support timezones from the TZ Database.
Static Public Member Functions | List of all members
ace_time::Epoch Class Reference

Utitliy functions for setting, retrieving, and converting the current epoch. More...

#include <Epoch.h>

Static Public Member Functions

static int16_t currentEpochYear ()
 Get the current epoch year.
 
static void currentEpochYear (int16_t year)
 Set the current epoch year.
 
static int32_t daysFromConverterEpoch (int16_t year)
 Return number of days to the given {year}-01-01 from the converter epoch of 2000-01-01.
 
static int32_t daysToCurrentEpochFromConverterEpoch ()
 Number of days from the converter epoch (2000-01-01) to the current epoch.
 
static int32_t daysToCurrentEpochFromUnixEpoch ()
 Return the number of days from the Unix epoch (1970-01-01T00:00:00) to the current epoch.
 
static int64_t secondsToCurrentEpochFromUnixEpoch64 ()
 Return the number of seconds from the Unix epoch (1970-01-01T00:00:00) to the current epoch. More...
 
static int16_t epochValidYearLower ()
 The smallest year (inclusive) for which calculations involving the 32-bit epoch_seconds and time zone transitions are guaranteed to be valid without underflowing or overflowing. More...
 
static int16_t epochValidYearUpper ()
 The largest year (exclusive) for which calculations involving the 32-bit epoch_seconds and time zone transitions are guaranteed to be valid without underflowing or overflowing. More...
 

Detailed Description

Utitliy functions for setting, retrieving, and converting the current epoch.

Normally, the default epoch is 2050-01-01T00:00:00 UTC. It can be changed by calling the currentEpochYear(year) function.

Definition at line 24 of file Epoch.h.

Member Function Documentation

◆ epochValidYearLower()

static int16_t ace_time::Epoch::epochValidYearLower ( )
inlinestatic

The smallest year (inclusive) for which calculations involving the 32-bit epoch_seconds and time zone transitions are guaranteed to be valid without underflowing or overflowing.

Valid years satisfy the condition year >= validYearLower(). This condition is not enforced by any code within the library. The limit is exposed for informational purposes for downstream applications.

A 32-bit integer has a range of about 136 years, so the half interval is 68 years. But the algorithms to calculate transitions in zone_processing.h use a 3-year window straddling the current year, so the actual lower limit is probably closer to currentEpochYear() - 66. To be conservative, this function returns currentEpochYear() - 50. It may return a smaller value in the future if the internal calculations can be verified to avoid underflow or overflow problems.

Definition at line 88 of file Epoch.h.

◆ epochValidYearUpper()

static int16_t ace_time::Epoch::epochValidYearUpper ( )
inlinestatic

The largest year (exclusive) for which calculations involving the 32-bit epoch_seconds and time zone transitions are guaranteed to be valid without underflowing or overflowing.

Valid years satisfy the condition year < validYearUpper(). This condition is not enforced by any code within the library. The limit is exposed for informational purposes for downstream applications.

A 32-bit integer has a range of about 136 years, so the half interval is 68 years. But the algorithms to calculate the transitions in zone_processing.h use a 3-year window straddling the current year, so actual upper limit is probably close to currentEpochYear() + 66. To be conservative, this function returns currentEpochYear() + 50. It may return a larger value in the future if the internal calculations can be verified to avoid underflow or overflow problems.

Definition at line 108 of file Epoch.h.

◆ secondsToCurrentEpochFromUnixEpoch64()

static int64_t ace_time::Epoch::secondsToCurrentEpochFromUnixEpoch64 ( )
inlinestatic

Return the number of seconds from the Unix epoch (1970-01-01T00:00:00) to the current epoch.

The return type is a 64-bit integer because a 32-bit integer would overflow if the current epoch year is set to later than 2038.

Definition at line 68 of file Epoch.h.


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