9#ifdef USE_TIME_TIMEZONE
82 const uint8_t weekday =
raw[LAYOUT.weekday_index()] & 0x7F;
83 day_of_week = weekday ? __builtin_ctz(weekday) + 1 : 1;
85 day_of_week =
raw[LAYOUT.weekday_index()] & 0x07;
87 day_of_week = (
raw[LAYOUT.weekday_index()] & 0x07) + 1;
90 if constexpr (LAYOUT.hour_12h) {
91 if ((
raw[2] & 0x40) != 0) {
97 if constexpr (LAYOUT.century_bit) {
98 if ((
raw[5] & 0x80) != 0)
105 .day_of_week = day_of_week,
119template<BcdCalendarLayout LAYOUT>
123 for (
size_t i = 0; i < 7; i++)
132 if constexpr (LAYOUT.century_bit) {
133 if (time.
year >= 2100)
This class simplifies creating components that periodically check a state.
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
virtual time_t timestamp_now()
Get the current time as the UTC epoch since January 1st 1970.
LazyCallbackManager< void()> time_sync_callback_
void add_on_time_sync_callback(F &&callback)
void dump_config() override
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
value[LAYOUT.day_index()]
ESPTime __attribute__((noinline)) RealTimeClock
constexpr BcdCalendarLayout EPSON_BCD_CALENDAR
Epson RX8025T, RX8111, RX8130.
BcdWeekday
How the weekday byte of a BCD calendar names the day, Sunday first.
@ ONE_HOT
one bit per day, bit 0 is Sunday
constexpr BcdCalendarLayout PCF_BCD_CALENDAR
PCF8563, PCF85063, BM8563.
constexpr BcdCalendarLayout DS_BCD_CALENDAR
DS1307, DS3231.
constexpr uint8_t uint8_to_bcd(uint8_t value)
Encode a value from 0 to 99 as a two-digit packed BCD byte, e.g. 59 to 0x59.
constexpr uint8_t bcd_to_uint8(uint8_t bcd)
Decode a two-digit packed BCD byte (tens in the high nibble) to its value, e.g. 0x59 to 59.
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
void recalc_timestamp_utc(bool use_day_of_year=true)
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC).
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
static ESPTime from_epoch_utc(time_t epoch)
Convert an UTC epoch timestamp to a UTC time ESPTime instance.
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
uint8_t day_of_week
day of the week; sunday=1 [1-7]
Layout of a 7-byte BCD calendar: second, minute, hour, weekday and day of the month in either order,...
bool century_bit
Bit 7 of the month byte is set from the year 2100 on. Chips without the bit read it as 0.
constexpr size_t day_index() const
bool hour_12h
Bit 6 of the hour byte selects 12-hour mode, with PM in bit 5; decoded only, encoding writes 24-hour ...
constexpr size_t weekday_index() const