Skip to content
Michael Miller edited this page Apr 27, 2023 · 10 revisions

(under construction)
RtcDateTime represents the time and date in one object. It is used to retrieve and set the time on the Rtc objects.

Constructors

explicit RtcDateTime(uint32_t secondsFrom2000)

Construct the RtcDateTime from seconds.
secondsFrom2000 - the number of seconds since Jan 1, 2000. This is not UNIX nor NTP date time.

RtcDateTime(uint16_t year, uint8_t month, uint8_t dayOfMonth, uint8_t hour, uint8_t minute, uint8_t second)

Construct the RtcDateTime from individual values of the date and time.

RtcDateTime(const char* date, const char* time)

Construct the RtcDateTime from the compilation format of date and time

    RtcDateTime compileDateTime(__DATE__, __TIME__);

Properties

bool IsValid() const

Basic validity test of values. It does not check time zones or daylight savings time.
<return>, true if values represent a valid date and time

uint16_t Year() const

<return>, the four digit year, like 2023.

uint8_t Month() const

<return>, the month

uint8_t Day() const

<return>, the day

uint8_t Hour() const

<return>, the hour, in 24 hours format

uint8_t Minute() const

<return>, the minutes

uint8_t Second() const

<return>, the seconds

uint8_t DayOfWeek() const

<return>, the day of the week, where the day of the week starts on Sunday with a value of 0. You can assign it to an enum DayOfWeek.

Operators

void operator += (uint32_t seconds)

This allows for seconds to added to the time.

    time += 60; // add a minute

Methods

uint32_t TotalSeconds() const

<return>, the total seconds since 1/1/2000. This is not UNIX time.

uint64_t TotalSeconds64() const;

<return>, the total seconds since 1/1/2000. This is not UNIX time.

uint32_t Unix32Time() const

<return>, a Unix time value.

void InitWithUnix32Time(uint32_t time)

time - a time value in 32 bit Unix time space.

uint64_t Unix64Time() const

<return>, a Unix time value.

void InitWithUnix64Time(uint64_t time)

time - a time value in 64 bit Unix time space.

uint32_t Ntp32Time() const

<return>, a NTP time value.

void InitWithNtp32Time(uint32_t time)

time - a time value in 32 bit NTP time space.

uint64_t Ntp64Time() const

<return>, a NTP time value.

void InitWithNtp64Time(uint64_t time)

time - a time value in 64 bit NTP time space.

Clone this wiki locally