MySQL 8.0.39
Source Code Documentation
tztime.h File Reference
#include "my_config.h"
#include "my_inttypes.h"
#include <sys/time.h>
#include "my_time_t.h"
#include "mysql_time.h"

Go to the source code of this file.

Classes

class  Time_zone
 This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t conversion. More...
 

Functions

Time_zonemy_tz_find (THD *thd, const String *name)
 Get Time_zone object for specified time zone. More...
 
bool my_tz_init (THD *org_thd, const char *default_tzname, bool bootstrap)
 
void my_tz_free ()
 
my_time_t sec_since_epoch_TIME (MYSQL_TIME *t)
 
bool check_time_zone_convertibility (const MYSQL_TIME &mt)
 Checks that this temporal value can be converted from its specified time zone (if any) to the current time zone. More...
 
bool convert_time_zone_displacement (const Time_zone *tz, MYSQL_TIME *mt)
 Converts a date/time value with time zone to the corresponding date/time value without time zone, converted to be in time zone specified by argument tz. More...
 
my_time_t use_input_time_zone (const MYSQL_TIME *input, bool *in_dst_time_gap)
 
void sec_to_TIME (MYSQL_TIME *tmp, my_time_t t, int64 offset)
 

Variables

Time_zonemy_tz_UTC
 
Time_zonemy_tz_SYSTEM
 
Time_zonemy_tz_OFFSET0
 
static const int MY_TZ_TABLES_COUNT = 4
 Number of elements in table list produced by my_tz_get_table_list() (this table list contains tables which are needed for dynamical loading of time zone descriptions). More...
 

Function Documentation

◆ check_time_zone_convertibility()

bool check_time_zone_convertibility ( const MYSQL_TIME mt)

Checks that this temporal value can be converted from its specified time zone (if any) to the current time zone.

Specifically, temporal values with zero months or days cannot be converted between time zones.

Parameters
mtThe time to check.
Return values
falseThe temporal value has no time zone or can be converted.
trueOtherwise, and an error was raised.

◆ convert_time_zone_displacement()

bool convert_time_zone_displacement ( const Time_zone tz,
MYSQL_TIME mt 
)

Converts a date/time value with time zone to the corresponding date/time value without time zone, converted to be in time zone specified by argument tz.

Since MySQL doesn't have a data type for temporal values with time zone information, all such values are converted to a value without time zone using this function.

This function is intended only for values with a time zone, and is a no-op for all other types.

The converted value may not fall outside the range of the DATETIME type. Also some invalid values cannot be converted because the conversion result would be undefined. In these cases an error is raised.

Parameters
tzThe time zone to convert according to.
[in,out]mtDate/Time value to be converted.
Returns
false on success. true if an error was raised.

◆ my_tz_find()

Time_zone * my_tz_find ( THD thd,
const String name 
)

Get Time_zone object for specified time zone.

Parameters
[in]thdPointer to thread THD structure.
[in]nameTime zone specification.
Note
This function checks if name is one of time zones described in db, predefined SYSTEM time zone or valid time zone specification as offset from UTC (In last case it will create proper Time_zone_offset object if there were not any.). If name is ok it returns corresponding Time_zone object.
Clients of this function are not responsible for releasing resources occupied by returned Time_zone object so they can just forget pointers to Time_zone object if they are not needed longer.
Other important property of this function: if some Time_zone found once it will be for sure found later, so this function can also be used for checking if proper Time_zone object exists (and if there will be error it will be reported during first call).
If name pointer is 0 then this function returns 0 (this allows to pass 0 values as parameter without additional external check and this property is used by @time_zone variable handling code).
It will perform lookup in system tables (mysql.time_zone*), opening and locking them, and closing afterwards. It won't perform such lookup if no time zone describing tables were found during server start up.
Return values
0bad time zone specification or other error.
Time_zoneobject pointer.

◆ my_tz_free()

void my_tz_free ( )

◆ my_tz_init()

bool my_tz_init ( THD org_thd,
const char *  default_tzname,
bool  bootstrap 
)

◆ sec_since_epoch_TIME()

my_time_t sec_since_epoch_TIME ( MYSQL_TIME t)

◆ sec_to_TIME()

void sec_to_TIME ( MYSQL_TIME tmp,
my_time_t  t,
int64  offset 
)

◆ use_input_time_zone()

my_time_t use_input_time_zone ( const MYSQL_TIME input,
bool *  in_dst_time_gap 
)

Variable Documentation

◆ my_tz_OFFSET0

Time_zone* my_tz_OFFSET0
extern

◆ my_tz_SYSTEM

Time_zone* my_tz_SYSTEM
extern

◆ MY_TZ_TABLES_COUNT

const int MY_TZ_TABLES_COUNT = 4
static

Number of elements in table list produced by my_tz_get_table_list() (this table list contains tables which are needed for dynamical loading of time zone descriptions).

Actually it is implementation detail that should not be used anywhere outside of tztime.h and tztime.cc.

◆ my_tz_UTC

Time_zone* my_tz_UTC
extern