Spec-Zone .ru
спецификации, руководства, описания, API

10.6.1. Staying Current with Time Zone Changes

As mentioned earlier, when the time zone rules change, applications that use the old rules become out of date. To stay current, it is necessary to make sure that your system uses current time zone information is used. For MySQL, there are two factors to consider in staying current:

If you are uncertain whether named time zones are available, for use either as the server's time zone setting or by clients that set their own time zone, check whether your time zone tables are empty. The following query determines whether the table that contains time zone names has any rows:

mysql> SELECT COUNT(*) FROM
        mysql.time_zone_name;+----------+| COUNT(*) |+----------+|        0 |+----------+

A count of zero indicates that the table is empty. In this case, no one can be using named time zones, and you don't need to update the tables. A count greater than zero indicates that the table is not empty and that its contents are available to be used for named time zone support. In this case, you should be sure to reload your time zone tables so that anyone who uses named time zones will get correct query results.

To check whether your MySQL installation is updated properly for a change in Daylight Saving Time rules, use a test like the one following. The example uses values that are appropriate for the 2007 DST 1-hour change that occurs in the United States on March 11 at 2 a.m.

The test uses these two queries:

SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');

The two time values indicate the times at which the DST change occurs, and the use of named time zones requires that the time zone tables be used. The desired result is that both queries return the same result (the input time, converted to the equivalent value in the 'US/Central' time zone).

Before updating the time zone tables, you would see an incorrect result like this:

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

After updating the tables, you should see the correct result:

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