AceTime  3.0.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

Utility 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 daysFromInternalEpoch (int16_t year)
 Return number of days to the given {year}-01-01 from the converter epoch of 2000-01-01.
 
static int32_t daysToCurrentEpochFromInternalEpoch ()
 Number of days from the internal epoch (2000-01-01) to the current epoch. More...
 
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

Utility 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

◆ daysToCurrentEpochFromInternalEpoch()

static int32_t ace_time::Epoch::daysToCurrentEpochFromInternalEpoch ( )
inlinestatic

Number of days from the internal epoch (2000-01-01) to the current epoch.

This is an internal implementation that is public for testing purposes.

Definition at line 50 of file Epoch.h.

◆ 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 89 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 109 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 69 of file Epoch.h.


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