ClockSupport.h file

Contains the epochStart class, which is a helper to convert between various time types used by different processors and the loggerClock class.

Classes

class epochTime
A class for dealing with different definitions of the start of the epoch.
class loggerClock
A class for the clock attached to the logger.

Enums

enum class epochStart: time_t { unix_epoch = 2208988800, y2k_epoch = 2208988800 + 946684800, gps_epoch = 2208988800 + 315964800, nist_epoch = 0 }
Set the epoch start value.

Defines

#define MS_USE_DS3231
Select DS3231 as the RTC for the EnviroDIY Mayfly.
#define MS_CLOCK_NAME = "DS3231"
A text description of the clock.
#define CLOCK_INTERRUPT_MODE = FALLING
The mode for the interrupt on the wake/RTC pin; must be one of HIGH, LOW, FALLING, RISING, or CHANGE.
#define EPOCH_NIST_TO_UNIX = 2208988800
The difference in seconds between the epoch value returned by the NIST Network Time Protocol and the Unix epoch.
#define EPOCH_UNIX_TO_Y2K = 946684800
The epoch starting Jan 1, 2000, as some RTC's and Arduinos do (946684800s ahead of UNIX epoch)
#define EPOCH_UNIX_TO_GPS = 315964800
The GPS epoch starting Jan 5, 1980 (was 315964800s ahead of UNIX epoch at founding, has drifted farther apart due to leap seconds)
#define NUMBER_LEAP_SECONDS = 18
The number of announced leap seconds as of February 24, 2025.
#define LEAP_SECONDS = {46828800, 78364801, 109900802, 173059203, 252028804, 315187205, \ 346723206, 393984007, 425520008, 457056009, 504489610, 551750411, \ 599184012, 820108813, 914803214, 1025136015, 1119744016, 1167264017}
The GPS epoch equivalent for each of the announced leap seconds as of February 24, 2025.

Enum documentation

enum class epochStart: time_t

Set the epoch start value.

Enumerators
unix_epoch

Use a Unix epoch, starting Jan 1, 1970. This is the default for this library.

y2k_epoch

Use an epoch starting Jan 1, 2000, as some RTC's and Arduinos do (946684800s ahead of UNIX epoch)

gps_epoch

Use the GPS epoch starting Jan 5, 1980 (was 315964800s ahead of UNIX epoch at founding, has drifted farther apart due to leap seconds)

nist_epoch

Use the epoch starting Jan 1, 1900 as returned by the NIST Network Time Protocol (RFC-1305 and later versions) and Time Protocol (RFC-868) (2208988800 behind the UNIX epoch)


Define documentation

#define CLOCK_INTERRUPT_MODE = FALLING

The mode for the interrupt on the wake/RTC pin; must be one of HIGH, LOW, FALLING, RISING, or CHANGE.

Using HIGH or LOW could trigger multiple interrupts when the clock interrupt fires. It's best to catch the first edge of the clock interrupt. So for an RTC with an active low interrupt, use "FALLING."


#define EPOCH_NIST_TO_UNIX = 2208988800

The difference in seconds between the epoch value returned by the NIST Network Time Protocol and the Unix epoch.

The NIST Network Time Protocol (RFC-1305 and later versions) and Time Protocol (RFC-868) both return a uint32_t which is the number of seconds from January 1, 1900. This is 2208988800 seconds behind the UNIX epoch.

The NIST epoch will roll over and cease to work for processors with a uint32_t time_t on February 7, 2036 6:28:15 AM.