PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Timezone database

Read access to the timezone database stored in resources. More...

Data Structures

struct  TimezoneDSTRule
 Transition between standard time and DST. More...
 

Enumerations

enum  DSTRuleFlags { TIMEZONE_FLAG_DAY_DECREMENT = 1 << 0 , TIMEZONE_FLAG_STANDARD_TIME = 1 << 1 , TIMEZONE_FLAG_UTC_TIME = 1 << 2 }
 Flags of a TimezoneDSTRule. More...
 

Functions

int timezone_database_get_region_count (void)
 Get the number of regions in the database.
 
bool timezone_database_load_region_info (uint16_t region_id, TimezoneInfo *tz_info)
 Load the timezone information of a region.
 
bool timezone_database_load_region_name (uint16_t region_id, char *region_name)
 Load the name of a region.
 
bool timezone_database_load_dst_rule (uint8_t dst_id, TimezoneDSTRule *start, TimezoneDSTRule *end)
 Load the pair of DST rules of a DST id.
 
int timezone_database_find_region_by_name (const char *region_name, int region_name_length)
 Find a region by name.
 

Detailed Description

Read access to the timezone database stored in resources.

The database holds the regions (continent/city name, UTC offset, abbreviation and DST rule index), pairs of DST rules, and links mapping legacy region names to regions.


Data Structure Documentation

◆ TimezoneDSTRule

struct TimezoneDSTRule

Transition between standard time and DST.

Matches the storage format exactly; do not change it without changing the database format.

Data Fields
char ds_label 'D' when entering DST, 'S' when entering standard time, or a NUL character if the timezone does not observe DST.
uint8_t flag DSTRuleFlags bits.
uint8_t hour Hour of the day; values of 24 and above roll over to the following days.
uint8_t mday Day of the month, starting at 1.
uint8_t minute Minute of the hour.
uint8_t month Month, 0 being January.
uint8_t wday Day of the week, 0 being Sunday, or 255 for any day.

Enumeration Type Documentation

◆ DSTRuleFlags

Flags of a TimezoneDSTRule.

Enumerator
TIMEZONE_FLAG_DAY_DECREMENT 

Search backwards, rather than forwards, from TimezoneDSTRule::mday for the weekday.

TIMEZONE_FLAG_STANDARD_TIME 

The transition time is in standard time rather than wall-clock time.

TIMEZONE_FLAG_UTC_TIME 

The transition time is in UTC rather than wall-clock time.

Function Documentation

◆ timezone_database_find_region_by_name()

int timezone_database_find_region_by_name ( const char *  region_name,
int  region_name_length 
)

Find a region by name.

Region names are matched on their first region_name_length characters. Links are searched next, as phones may send legacy names such as "US/Pacific".

Parameters
region_nameName to look up, need not be NUL terminated.
region_name_lengthLength of region_name.
Returns
Region id, or -1 if not found.

◆ timezone_database_get_region_count()

int timezone_database_get_region_count ( void  )

Get the number of regions in the database.

Returns
Number of regions.

◆ timezone_database_load_dst_rule()

bool timezone_database_load_dst_rule ( uint8_t  dst_id,
TimezoneDSTRule *  start,
TimezoneDSTRule *  end 
)

Load the pair of DST rules of a DST id.

Parameters
dst_idDST rule index, starting at 1.
[out]startRule entering DST.
[out]endRule leaving DST.
Returns
True on success, false if dst_id is invalid, the timezone does not observe DST or the database is malformed.

◆ timezone_database_load_region_info()

bool timezone_database_load_region_info ( uint16_t  region_id,
TimezoneInfo *  tz_info 
)

Load the timezone information of a region.

TimezoneInfo::dst_start and TimezoneInfo::dst_end are set to 0; the DST period is not computed.

Parameters
region_idRegion to look up.
[out]tz_infoTimezone information.
Returns
True on success, false if the database could not be read.

◆ timezone_database_load_region_name()

bool timezone_database_load_region_name ( uint16_t  region_id,
char *  region_name 
)

Load the name of a region.

Parameters
region_idRegion to look up.
[out]region_nameNUL terminated "continent/city" name, in a buffer of at least TIMEZONE_NAME_LENGTH bytes.
Returns
True on success, false if region_id is invalid.