php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
parse_tz.c File Reference
#include "timelib.h"
#include "timelib_private.h"
#include "timezonedb.h"

Go to the source code of this file.

Macros

#define TIMELIB_SUPPORTS_V2DATA
 
#define TIMELIB_SUPPORT_SLIM_FILE
 
#define timelib_conv_int_signed(value)
 
#define timelib_conv_int64_signed(value)
 

Functions

void timelib_dump_tzinfo (timelib_tzinfo *tz)
 
const timelib_tzdbtimelib_builtin_db (void)
 
const timelib_tzdb_index_entrytimelib_timezone_identifiers_list (const timelib_tzdb *tzdb, int *count)
 
int timelib_timezone_id_is_valid (const char *timezone, const timelib_tzdb *tzdb)
 
timelib_tzinfotimelib_parse_tzfile (const char *timezone, const timelib_tzdb *tzdb, int *error_code)
 
void timelib_tzinfo_dtor (timelib_tzinfo *tz)
 
timelib_tzinfotimelib_tzinfo_clone (timelib_tzinfo *tz)
 
ttinfotimelib_fetch_timezone_offset (timelib_tzinfo *tz, timelib_sll ts, timelib_sll *transition_time)
 
int timelib_timestamp_is_in_dst (timelib_sll ts, timelib_tzinfo *tz)
 
timelib_time_offsettimelib_get_time_zone_info (timelib_sll ts, timelib_tzinfo *tz)
 
int timelib_get_time_zone_offset_info (timelib_sll ts, timelib_tzinfo *tz, int32_t *offset, timelib_sll *transition_time, unsigned int *is_dst)
 
timelib_sll timelib_get_current_offset (timelib_time *t)
 
int timelib_same_timezone (timelib_time *one, timelib_time *two)
 

Macro Definition Documentation

◆ timelib_conv_int64_signed

#define timelib_conv_int64_signed ( value)
Value:
((int64_t) timelib_conv_int64_unsigned((int64_t) value))
value

Definition at line 92 of file parse_tz.c.

◆ timelib_conv_int_signed

#define timelib_conv_int_signed ( value)
Value:
((int32_t) timelib_conv_int_unsigned((int32_t) value))

Definition at line 91 of file parse_tz.c.

◆ TIMELIB_SUPPORT_SLIM_FILE

#define TIMELIB_SUPPORT_SLIM_FILE

Definition at line 30 of file parse_tz.c.

◆ TIMELIB_SUPPORTS_V2DATA

#define TIMELIB_SUPPORTS_V2DATA

Definition at line 29 of file parse_tz.c.

Function Documentation

◆ timelib_builtin_db()

const timelib_tzdb * timelib_builtin_db ( void )

Returns a pointer to the built-in time zone database.

You must not free the returned pointer as it is part of the text segment.

Definition at line 606 of file parse_tz.c.

◆ timelib_dump_tzinfo()

void timelib_dump_tzinfo ( timelib_tzinfo * tz)

Displays debugging information about the time zone information in 'tz'.

Definition at line 510 of file parse_tz.c.

◆ timelib_fetch_timezone_offset()

ttinfo * timelib_fetch_timezone_offset ( timelib_tzinfo * tz,
timelib_sll ts,
timelib_sll * transition_time )

Algorithm From RFC 8536, Section 3.2 https://tools.ietf.org/html/rfc8536#section-3.2

Definition at line 790 of file parse_tz.c.

◆ timelib_get_current_offset()

timelib_sll timelib_get_current_offset ( timelib_time * t)

Returns the UTC offset currently applicable for the information stored in 't'.

The value returned is the UTC offset in seconds East.

Definition at line 937 of file parse_tz.c.

◆ timelib_get_time_zone_info()

timelib_time_offset * timelib_get_time_zone_info ( timelib_sll ts,
timelib_tzinfo * tz )

Returns offset information with time zone 'tz' for the time stamp 'ts'.

The returned information contains: the offset in seconds East of UTC (in 'offset'), whether DST is active ('is_dst'), what the current time zone abbreviation is ('abbr') and the transition time that got to this state (in 'transition_time');

Definition at line 881 of file parse_tz.c.

◆ timelib_get_time_zone_offset_info()

int timelib_get_time_zone_offset_info ( timelib_sll ts,
timelib_tzinfo * tz,
int32_t * offset,
timelib_sll * transition_time,
unsigned int * is_dst )

Returns offset information with time zone 'tz' for the time stamp 'ts'.

The returned information contains: the offset in seconds East of UTC (in the output parameter 'offset'), whether DST is active (in the output parameter 'is_dst'), and the transition time that got to this state (in the output parameter 'transition_time'); if NULL is passed, the value is not retrieved

Returns 1 if successful, 0 for failure.

Definition at line 913 of file parse_tz.c.

◆ timelib_parse_tzfile()

timelib_tzinfo * timelib_parse_tzfile ( const char * timezone,
const timelib_tzdb * tzdb,
int * error_code )

Converts the binary stored time zone information from 'tzdb' for the time zone 'timezone' into a structure the library can use for calculations.

The function can be used on both timelib_builtin_db as well as a time zone db as opened by timelib_zoneinfo.

'error_code' must not be a null pointer, and will always be written to. If the value is TIMELIB_ERROR_NO_ERROR then the file was parsed without problems.

The function will return null upon failure, and also set an error code through 'error_code'.

The error code is one of the TIMELIB_ERROR_* constants as listed above. These error constants can be converted into a string by timelib_get_error_message.

If the function returns not-null, the 'error_code' might have a non-null value that can be used to detect incompatibilities. The only one that is currently detected is whether the file is a 'slim' file, in which case 'error_code' will be set to TIMELIB_ERROR_SLIM_FILE.

This function allocates memory for the new time zone structure, which must be freed after use. Although it is recommended that a cache of each used time zone is kept.

Definition at line 662 of file parse_tz.c.

◆ timelib_same_timezone()

int timelib_same_timezone ( timelib_time * one,
timelib_time * two )

Returns whether the timezone information in *one and *two are the same

A timezone is considered the same if:

  • the ->zone_type values are the same for *one and *two
  • for TYPE_ABBR and TYPE_OFFSET, ->z + (->dst * 3600), is the same
  • for TYPE_ID, the zone's names are the same

Definition at line 955 of file parse_tz.c.

◆ timelib_timestamp_is_in_dst()

int timelib_timestamp_is_in_dst ( timelib_sll ts,
timelib_tzinfo * tz )

Returns whether DST is active with time zone 'tz' for the time stamp 'ts'.

Returns 0 if DST is not active, 1 if DST is active, or -1 if no transitions were available through 'tz'.

Definition at line 870 of file parse_tz.c.

◆ timelib_timezone_id_is_valid()

int timelib_timezone_id_is_valid ( const char * timezone,
const timelib_tzdb * tzdb )

Returns whether the time zone ID 'timezone' is available in the time zone database as pointed to be 'tzdb'.

Definition at line 617 of file parse_tz.c.

◆ timelib_timezone_identifiers_list()

const timelib_tzdb_index_entry * timelib_timezone_identifiers_list ( const timelib_tzdb * tzdb,
int * count )

Returns a pointer to the start of an array containing a list of timezone identifiers.

The amount of entries in the array is returned through the 'count' OUT parameter.

Each entry contains the time zone ID ('id' field), and the position within the time zone information ('pos' field). The pos field should not be used.

Definition at line 611 of file parse_tz.c.

◆ timelib_tzinfo_clone()

timelib_tzinfo * timelib_tzinfo_clone ( timelib_tzinfo * tz)

Deep-clones a timelib_tzinfo structure.

This allocates resources that need to be freed with 'timelib_tzinfo_dtor'

Definition at line 745 of file parse_tz.c.

◆ timelib_tzinfo_dtor()

void timelib_tzinfo_dtor ( timelib_tzinfo * tz)

Frees up the resources allocated by 'timelib_parse_tzfile'.

Definition at line 728 of file parse_tz.c.