#include <SystemClock.h>
◆ CheckTimeZoneOffset
Optional callback which can be used to automate handling of timezone changes.
- Parameters
-
| systemTime | The current system time |
Although the timezone offset only changes twice a year, when it does change the corresponding offset should be updated promptly.
setTimeZoneOffset() is typically called when updating via real-time clock chip or NTP, but this can still leave a considerable gap during which the local time will be wrong.
The callback should check the provided systemTime and determine if the time zone offset requires changing and, if so, call setTimeZoneOffset(). One way to make this efficient is to cache the time_t value for the next change, rather than attemtpting to compute the offset on every call.
◆ getSystemTimeString()
Get current time as a string.
- Parameters
-
| timeType | Time zone to present time as, i.e. return local or UTC time |
- Return values
-
| String | Current time in format: dd.mm.yy hh:mm:ss |
◆ getTimeZone()
Get current time zone information.
- Return values
-
◆ getTimeZoneOffset()
| int SystemClockClass::getTimeZoneOffset |
( |
| ) |
const |
|
inline |
Get the current time zone offset.
- Return values
-
| int | Offset in seconds from UTC |
◆ isSet()
| bool SystemClockClass::isSet |
( |
| ) |
const |
|
inline |
Determine if setTime() has been called yet.
- Note
- Indicates whether time returned can be relied upon
◆ now()
Get the current date and time.
- Parameters
-
| timeType | Time zone to use (UTC / local) |
- Return values
-
◆ onCheckTimeZoneOffset()
Set/clear a callback which is invoked whenever local time is queried.
- Note
- This callback is only invoked when
now() is called.
◆ setTime()
| bool SystemClockClass::setTime |
( |
time_t |
time, |
|
|
TimeZone |
timeType |
|
) |
| |
Set the system clock's time.
- Parameters
-
| time | Unix time to set clock to (quantity of seconds since 00:00:00 1970-01-01) |
| timeType | Time zone of Unix time, i.e. is time provided as local or UTC? |
- Note
- System time is always stored as UTC time. If setting using the value retrieved from a time server using NTP, specify eTZ_UTC. If passing a local value using eTZ_Local, ensure that the time zone has been set correctly as it will be converted to UTC before storing.
◆ setTimeZone() [1/2]
Set current time zone information.
- Parameters
-
| zoneInfo | Contains offset plus string formatting information |
◆ setTimeZone() [2/2]
| void SystemClockClass::setTimeZone |
( |
float |
localTimezoneOffset | ) |
|
|
inline |
Set the local time zone offset in hours.
- Parameters
-
| localTimezoneOffset | Offset from UTC of local time zone in hours |
- Return values
-
| bool | true on success, false if value out of range |
- Note
- Values for local standard time may exceed +/- 12 For example, Pacific/Kiritimati has a 14-hour offset (in 2024).
◆ setTimeZoneOffset()
| void SystemClockClass::setTimeZoneOffset |
( |
int |
seconds | ) |
|
|
inline |
Sets the local time zone offset.
- Parameters
-
| seconds | Offset from UTC of local time zone in seconds |
- See also
- See
setTimeZone().
The documentation for this class was generated from the following file: