PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
Time zone

The system time zone, and conversions between UTC and local time. More...

Data Structures

struct  pbl_tz
 Time zone. More...
 

Functions

void pbl_tz_set (const struct pbl_tz *tz)
 Set the system time zone.
 
int32_t pbl_tz_gmtoff (void)
 Get the offset of the time zone from UTC, without DST.
 
int32_t pbl_tz_dst_offset (void)
 Get the offset added during DST.
 
time_t pbl_tz_dst_start (void)
 Get the start of the current or next DST period.
 
bool pbl_tz_is_dst (time_t utc_time)
 Check whether DST applies at a given time.
 
void pbl_tz_abbr (char *buf, time_t utc_time)
 Get the time zone abbreviation in effect at a given time.
 
time_t pbl_tz_utc_to_local (time_t utc_time)
 Convert UTC time to local time.
 
time_t pbl_tz_local_to_utc (time_t local_time)
 Convert local time to UTC 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.
 

Detailed Description

The system time zone, and conversions between UTC and local time.

The kernel keeps one time zone for the whole system: its offset from UTC, its abbreviations and up to two daylight saving time (DST) periods, the current or next one and the one before it. Whoever knows the time zone sets it with pbl_tz_set(); until then, local time is UTC.

time_t now = pbl_realtime();
struct pbl_tm tm;
pbl_localtime_r(&now, &tm);
time_t pbl_realtime(void)
Get the wall clock 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.
structure containing broken-down time for expressing calendar time (ie.
Definition time.h:23

Data Structure Documentation

◆ pbl_tz

struct pbl_tz

Time zone.

Data Fields
char dst_abbr[PBL_TZ_LEN] Abbreviation during DST, NUL terminated.
time_t dst_end UTC end of the current or next DST period, 0 if none.
int32_t dst_offset Offset added to gmtoff during DST, in seconds.
time_t dst_start UTC start of the current or next DST period, 0 if none.
int32_t gmtoff Offset from UTC outside DST, in seconds.
time_t prev_dst_end UTC end of the DST period before dst_start, 0 if none.
time_t prev_dst_start UTC start of the DST period before dst_start, 0 if none.
char std_abbr[PBL_TZ_LEN] Abbreviation outside DST, NUL terminated.

Function Documentation

◆ pbl_localtime_r()

struct pbl_tm * pbl_localtime_r ( const time_t *  timep,
struct pbl_tm *  result 
)

Convert seconds since the epoch to broken-down local time.

Parameters
timepSeconds since the Unix epoch.
[out]resultBroken-down time, in the system time zone.
Returns
result.

◆ pbl_tz_abbr()

void pbl_tz_abbr ( char *  buf,
time_t  utc_time 
)

Get the time zone abbreviation in effect at a given time.

Parameters
[out]bufBuffer of PBL_TZ_LEN bytes, receives a NUL terminated abbreviation.
utc_timeUTC time, deciding whether DST applies.

◆ pbl_tz_dst_offset()

int32_t pbl_tz_dst_offset ( void  )

Get the offset added during DST.

Returns
Offset in seconds.

◆ pbl_tz_dst_start()

time_t pbl_tz_dst_start ( void  )

Get the start of the current or next DST period.

Returns
UTC time, 0 if none.

◆ pbl_tz_gmtoff()

int32_t pbl_tz_gmtoff ( void  )

Get the offset of the time zone from UTC, without DST.

Returns
Offset in seconds.

◆ pbl_tz_is_dst()

bool pbl_tz_is_dst ( time_t  utc_time)

Check whether DST applies at a given time.

Parameters
utc_timeUTC time.
Returns
true if utc_time falls within a DST period.

◆ pbl_tz_local_to_utc()

time_t pbl_tz_local_to_utc ( time_t  local_time)

Convert local time to UTC time.

Ambiguous during the hour repeated when DST ends.

Parameters
local_timeLocal time.
Returns
UTC time.

◆ pbl_tz_set()

void pbl_tz_set ( const struct pbl_tz *  tz)

Set the system time zone.

Parameters
tzNew time zone.

◆ pbl_tz_utc_to_local()

time_t pbl_tz_utc_to_local ( time_t  utc_time)

Convert UTC time to local time.

Parameters
utc_timeUTC time.
Returns
Local time.