TTZ
Loading...
Searching...
No Matches
ttz.h File Reference
#include "stdint.h"

Go to the source code of this file.

Enumerations

enum  ttz_match_t { TTZ_NONE , TTZ_EXACT , TTZ_SCORE }
 
enum  ttz_error_t { TTZ_SUCCESS , TTZ_NO_MATCH , TTZ_INVALID_INDEX , TTZ_MULTI_ZONES }
 

Functions

uint8_t ttz_render_country_name (uint8_t idx, char *buf)
 
uint8_t ttz_render_official_name (uint8_t idx, char *buf)
 
uint8_t ttz_render_country_code (uint8_t idx, char *buf)
 
uint8_t ttz_render_city (uint16_t idx, char *buf)
 
uint8_t ttz_render_zone_code (uint16_t idx, char *buf)
 
ttz_match_t ttz_find_country (char *s, uint8_t count, uint8_t *idx, uint8_t *scores)
 
ttz_match_t ttz_find_city (char *s, uint8_t count, uint16_t *idx, uint8_t *scores)
 
ttz_match_t ttz_find_country_code (char *s, uint8_t *idx)
 
ttz_match_t ttz_find_zone_code (char *s, uint16_t *idx)
 
ttz_error_t ttz_offset_by_zone_code (uint16_t idx, int64_t timestamp, int *offset)
 
ttz_error_t ttz_offset_by_city (uint16_t idx, int64_t timestamp, int *offset)
 
ttz_error_t ttz_offset_by_country (uint8_t idx, int64_t timestamp, int *offset)
 

Enumeration Type Documentation

◆ ttz_error_t

Enumerator
TTZ_SUCCESS 

No error.

TTZ_NO_MATCH 

No match found.

TTZ_INVALID_INDEX 

Out of bounds index provided.

TTZ_MULTI_ZONES 

Multiple zones found for the given country.

◆ ttz_match_t

Enumerator
TTZ_NONE 

No match found.

TTZ_EXACT 

We found an exact match.

TTZ_SCORE 

No exact match, so we return a list of matches ranked by scores

Function Documentation

◆ ttz_find_city()

ttz_match_t ttz_find_city ( char * s,
uint8_t count,
uint16_t * idx,
uint8_t * scores )

Search for a city from a query string

Parameters
[in]sThe query string.
[in]countIn case of non-exact match, the number of matches to return.
[out]idxThe city indeces of the matches.
[out]scoresThe scores of the matches.
Returns
The match type.

◆ ttz_find_country()

ttz_match_t ttz_find_country ( char * s,
uint8_t count,
uint8_t * idx,
uint8_t * scores )

Search for a country code from a query string

Parameters
[in]sThe query string.
[in]countIn case of non-exact match, the number of matches to return.
[out]idxThe country indeces of the matches.
[out]scoresThe scores of the matches.
Returns
The match type.

◆ ttz_find_country_code()

ttz_match_t ttz_find_country_code ( char * s,
uint8_t * idx )

Search for a country code from a query string using exact match.

Parameters
[in]sThe query string.
[out]idxThe country index.
Returns
The match type.

◆ ttz_find_zone_code()

ttz_match_t ttz_find_zone_code ( char * s,
uint16_t * idx )

Search for a zone code from a query string using exact match.

Parameters
[in]sThe query string.
[out]idxThe zone index.
Returns
The match type.

◆ ttz_offset_by_city()

ttz_error_t ttz_offset_by_city ( uint16_t idx,
int64_t timestamp,
int * offset )

Get the offset for a given city index and timestamp.

Parameters
[in]idxThe city index.
[in]timestampThe timestamp.
[out]offsetThe offset.
Returns
The error code.

◆ ttz_offset_by_country()

ttz_error_t ttz_offset_by_country ( uint8_t idx,
int64_t timestamp,
int * offset )

Get the offset for a given country index and timestamp.

Parameters
[in]idxThe country index.
[in]timestampThe timestamp.
[out]offsetThe offset.
Returns
The error code.

◆ ttz_offset_by_zone_code()

ttz_error_t ttz_offset_by_zone_code ( uint16_t idx,
int64_t timestamp,
int * offset )

Get the offset for a given zone index and timestamp.

Parameters
[in]idxThe zone index.
[in]timestampThe timestamp.
[out]offsetThe offset.
Returns
The error code.

◆ ttz_render_city()

uint8_t ttz_render_city ( uint16_t idx,
char * buf )

Render the city name for a given city index.

Parameters
[in]idxThe city index.
[out]bufThe buffer to write the city name to.
Returns
The length of the city name.

◆ ttz_render_country_code()

uint8_t ttz_render_country_code ( uint8_t idx,
char * buf )

Render the country code for a given country index.

Parameters
[in]idxThe country index.
[out]bufThe buffer to write the country code to.
Returns
The length of the country code.

◆ ttz_render_country_name()

uint8_t ttz_render_country_name ( uint8_t idx,
char * buf )

Render the country name for a given country index.

Parameters
[in]idxThe country index.
[out]bufThe buffer to write the country name to.
Returns
The length of the country name.

◆ ttz_render_official_name()

uint8_t ttz_render_official_name ( uint8_t idx,
char * buf )

Render the official name for a given country index.

Parameters
[in]idxThe country index.
[out]bufThe buffer to write the official name to.
Returns
The length of the official name.

◆ ttz_render_zone_code()

uint8_t ttz_render_zone_code ( uint16_t idx,
char * buf )

Render the zone code for a given zone index.

Parameters
[in]idxThe zone index.
[out]bufThe buffer to write the zone code to.
Returns
The length of the zone code.