|
PebbleOS v4.47.0-512-g5285d4236
|
Timezone, DST and local time conversions. More...
Data Structures | |
| struct | TimezoneInfo |
| Timezone information, small enough to be kept in RTC registers. More... | |
Macros | |
| #define | DSTID_BRAZIL 6 |
| DST rule index of Brazil. | |
| #define | DSTID_LORDHOWE 20 |
| DST rule index of Lord Howe Island, whose DST offset is half an hour. | |
Functions | |
| void | time_get_timezone_abbr (char *out_buf, time_t utc_time) |
| Get the timezone abbreviation in effect at a given time. | |
| struct pbl_tm * | pbl_localtime_r (const time_t *timep, struct pbl_tm *result) |
| Convert seconds since the epoch to broken-down local time. | |
| size_t | pbl_strftime_r (char *s, size_t maxsize, const char *format, const struct pbl_tm *tim_p) |
| Format broken-down time, in the language of the firmware. | |
| int32_t | time_get_gmtoffset (void) |
| Get the offset of the timezone from UTC, without DST. | |
| bool | time_get_isdst (time_t utc_time) |
| Check whether a time falls within the DST period. | |
| int32_t | time_get_dstoffset (void) |
| Get the offset added during DST. | |
| time_t | time_get_dst_start (void) |
| Get the start of the DST period. | |
| time_t | time_utc_to_local (time_t utc_time) |
| Convert UTC time, as returned by pbl_realtime(), to local time. | |
| time_t | time_local_to_utc (time_t local_time) |
| Convert local time to UTC time. | |
| void | time_util_update_timezone (const TimezoneInfo *tz_info, time_t prev_dst_start, time_t prev_dst_end) |
| Set the current timezone. | |
| time_t | time_util_get_midnight_of (time_t ts) |
| Get the local midnight starting the day of a time. | |
| bool | time_util_range_spans_day (time_t start, time_t end, time_t start_of_day) |
| Check whether a range covers a whole day. | |
| time_t | sys_time_utc_to_local (time_t t) |
| Syscall wrapper of time_utc_to_local(), for unprivileged code. | |
| time_t | time_util_utc_to_local_offset (void) |
| Get the current offset of local time from UTC, including DST. | |
| uint16_t | time_util_get_day (time_t utc_sec) |
| Get the local day index of a time. | |
| enum pbl_weekday | time_util_get_day_in_week (time_t utc_sec) |
| Get the local day of the week of a time. | |
| int | time_util_get_minute_of_day (time_t utc_sec) |
| Get the local minute of the day of a time. | |
| time_t | time_start_of_today (void) |
| Return the UTC time that corresponds to the start of today (midnight). | |
| uint32_t | time_get_uptime_seconds (void) |
| Get the time since boot. | |
Timezone, DST and local time conversions.
Holds the current timezone and its DST period, set from the phone or the timezone database, and converts between UTC and local time accordingly.
| struct TimezoneInfo |
Timezone information, small enough to be kept in RTC registers.
| Data Fields | ||
|---|---|---|
| time_t | dst_end | UTC timestamp of the end of the DST period, 0 if none. |
| uint8_t | dst_id | DST rule index. |
| time_t | dst_start | UTC timestamp of the start of the DST period, 0 if none. |
| int16_t | timezone_id | Olson index of the timezone. |
| int32_t | tm_gmtoff | Offset from UTC in seconds, without DST. |
| char | tm_zone[PBL_TZ_LEN - 1] |
Abbreviation, up to 5 characters, not NUL terminated. A |
| #define DSTID_BRAZIL 6 |
DST rule index of Brazil.
DST ids index the rules generated by tools/timezones.py from the Olson database; do not change them independently. Ids not listed here switch by one hour on the same spring and autumn days every year. Morocco's rules, which suspend DST for Ramadan, are not handled correctly.
| #define DSTID_LORDHOWE 20 |
DST rule index of Lord Howe Island, whose DST offset is half an hour.
Convert seconds since the epoch to broken-down local time.
| timep | Seconds since the Unix epoch. | |
| [out] | result | Broken-down time, in the current timezone. |
result. | size_t pbl_strftime_r | ( | char * | s, |
| size_t | maxsize, | ||
| const char * | format, | ||
| const struct pbl_tm * | tim_p | ||
| ) |
Format broken-down time, in the language of the firmware.
| [out] | s | Output buffer. |
| maxsize | Size of s. | |
| format | strftime() format. | |
| tim_p | Broken-down time. |
s is too small. | time_t sys_time_utc_to_local | ( | time_t | t | ) |
Syscall wrapper of time_utc_to_local(), for unprivileged code.
| t | UTC time. |
| time_t time_get_dst_start | ( | void | ) |
Get the start of the DST period.
| int32_t time_get_dstoffset | ( | void | ) |
Get the offset added during DST.
| int32_t time_get_gmtoffset | ( | void | ) |
Get the offset of the timezone from UTC, without DST.
| bool time_get_isdst | ( | time_t | utc_time | ) |
Check whether a time falls within the DST period.
| utc_time | UTC time. |
| void time_get_timezone_abbr | ( | char * | out_buf, |
| time_t | utc_time | ||
| ) |
Get the timezone abbreviation in effect at a given time.
| [out] | out_buf | Buffer of PBL_TZ_LEN bytes, receives a NUL terminated abbreviation. |
| utc_time | Time used to decide whether DST applies. |
| uint32_t time_get_uptime_seconds | ( | void | ) |
Get the time since boot.
Based on the tick count, so unaffected by changes of the wall-clock time.
| time_t time_local_to_utc | ( | time_t | local_time | ) |
Convert local time to UTC time.
Ambiguous during the hour repeated when DST ends.
| local_time | Local time. |
| time_t time_start_of_today | ( | void | ) |
Return the UTC time that corresponds to the start of today (midnight).
| time_t time_utc_to_local | ( | time_t | utc_time | ) |
Convert UTC time, as returned by pbl_realtime(), to local time.
| utc_time | UTC time. |
| uint16_t time_util_get_day | ( | time_t | utc_sec | ) |
Get the local day index of a time.
The index increments every day at local midnight.
| utc_sec | UTC time. |
| enum pbl_weekday time_util_get_day_in_week | ( | time_t | utc_sec | ) |
Get the local day of the week of a time.
| utc_sec | UTC time. |
| time_t time_util_get_midnight_of | ( | time_t | ts | ) |
Get the local midnight starting the day of a time.
| ts | UTC time. |
| int time_util_get_minute_of_day | ( | time_t | utc_sec | ) |
Get the local minute of the day of a time.
| utc_sec | UTC time. |
| bool time_util_range_spans_day | ( | time_t | start, |
| time_t | end, | ||
| time_t | start_of_day | ||
| ) |
Check whether a range covers a whole day.
| start | Start of the range. |
| end | End of the range. |
| start_of_day | Start of the day. |
start_of_day. | void time_util_update_timezone | ( | const TimezoneInfo * | tz_info, |
| time_t | prev_dst_start, | ||
| time_t | prev_dst_end | ||
| ) |
Set the current timezone.
| tz_info | New timezone, including its DST period. |
| prev_dst_start | UTC start of the DST period before tz_info's, 0 if none. |
| prev_dst_end | UTC end of the DST period before tz_info's, 0 if none. |
| time_t time_util_utc_to_local_offset | ( | void | ) |
Get the current offset of local time from UTC, including DST.