Home > database >  Daylight saving time function test
Daylight saving time function test

Time:10-09

[daylight saving time]
Daylight saving time is also called the summer to save time, it is to point to in the summer when the sun rises early, the clock ahead one hour, in order to improve the use of sunlight, support time zone is the precondition of support daylight saving time, different time zone support for daylight saving time is different, only in the use of daylight saving time zone, daylight saving time can play a role,
In America, for example:
Since 2007, every year the second Sunday of march at 2 PM, the first Sunday of November until 2 o 'clock in the morning, as the daylight saving time, other time for winter time or local standard time,

[parameter specification]
System_time_zone parameters: according to the operating system time zone,
Time_zone: gbase used in current session time zone, the session variable, can be used in the configuration file on time - zone - the default Settings, or using the set time_zone modified,

Time_zone value has three forms:
A) system: the value of the time_zone with system_time_zone values are the same, if not set in the configuration file, the value is the default value,
B) UTC offset said: scope for [- thou 13:00], for example from the '+' said is east eight area,
C) time zones: from time_zone_name can find out the time zone name, such as Asia/Shanghai said Shanghai's time zone,

[system table]
Time zone used system table is as follows:
Time_zone
Time_zone_name
Time_zone_transition
Time_zone_transition_type

Support the leap second time need to use the table below:
Time_zone_leap_second

Cluster 8.6.2 Build33 version after the installation, has good load time zone system tables,
Upgrade, need to manually load gbase_time_zone. SQL system tables, to the time zone in the installation package gcinstall directory gbase_data_timezone. SQL file,
Perform gccli - uroot - Dgbase & lt; Gbase_data_timezone. SQL, and various gnode node execution gncli - u root - DgbaseStop the cluster; Make the time zone and then restart the cluster effect,

[using a different time zone]
Gbase> The set time_zone='+ 8;
Query OK, 0 rows affected (Elapsed: 00:00:00. 00)

Gbase> Show variables like '% time_zone %';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
| system_time_zone | CST |
| time_zone + 08:00 | |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
2 rows in the set (Elapsed: 00:00:00. 00)

Gbase> The set time_zone='SYSTEM';
Query OK, 0 rows affected (Elapsed: 00:00:00. 00)

Gbase> Show variables like '% time_zone %';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
| system_time_zone | CST |
| time_zone | SYSTEM |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
2 rows in the set (Elapsed: 00:00:00. 00)

Gbase> The set time_zone='US/Central;
Query OK, 0 rows affected (Elapsed: 00:00:00. 00)

if the database cannot normal support daylight saving time, this process, an "ERROR 1298 (HY000) : Unknown or incorrect time zone: 'US/Central'"

Gbase> Show variables like '% time_zone %';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- +
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- +
| system_time_zone | CST |
| time_zone | US/Central |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- +
2 rows in the set (Elapsed: 00:00:00. 00)

[use daylight saving time]
a) in the summer time, the system at the same time, in time with gbase
Modify the system time zone
Cp/usr/share/zoneinfo/US/Pacific/etc/localtime
Modify system time to daylight saving time:
/root @ localhost ~ # date -s' 2017-3-11 5:00:00 '
The Sat Mar 11 05:00:00 PST 2017
/root @ localhost ~ # hwclock -w
/root @ localhost ~ # date '+ Y % % m - H: % d % % m: % S'
The 2017-03-11 05:04:22

Gbase> The set time_zone='SYSTEM';
Query OK, 0 rows affected (Elapsed: 00:00:00. 00)
Gbase> Show variables like '% % zone;
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
| system_time_zone | PST |
| time_zone | SYSTEM |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
2 rows in the set (Elapsed: 00:00:00. 00)
Gbase> The \! The date '+ Y % % m - H: % d % % m: % S'
The 2017-03-11 05:06:06
Gbase> The select now ();
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
| | now ()
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
05:06:10 | 2017-03-11 |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
1 row in the set (Elapsed: 00:00:00. 00)

The \! The date as a result of the operating system time, Select time now () is the result of the database, database and operating system at the same time, the system time zone support daylight saving time, database support daylight saving time,

b) convert_tz function, in support of daylight saving time zone conversion,
Gbase> SELECT CONVERT_TZ (' 2:00:00 2007-03-11 ', 'US/Eastern', 'US/Central');
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
2:00:00 | CONVERT_TZ (' 2007-03-11 ', 'US/Eastern', 'US/Central') |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
01:00:00 | 2007-03-11 |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
1 row in the set (Elapsed: 00:00:00. 02)

Gbase> SELECT CONVERT_TZ (' 3:00:00 2007-03-11 ', 'US/Eastern', 'US/Central');
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
3:00:00 | CONVERT_TZ (' 2007-03-11 ', 'US/Eastern', 'US/Central') |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
01:00:00 | 2007-03-11 |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +

If the database properly support daylight saving time, the above result sets NULL,

  • Related