I have spent the past hour trying different Google searches and I can't find any detailed description of the MYSQL timezone tables. I have looked at them, but that is not enough for me to figure them out (at least yet).
I don't mind reading the manual, but can anyone point me to one that describes the structure of these tables?
Then I want to generate SQL that can take a Timezone name and produce a timezone abbreviation. And then the reverse that goes from abbreviation and country code to timezone name. I have found some suggested SQL that does some of this, but I am hesitant to use those without some understanding of the tables they access.
/*
Input: sourcedt : Input datetime string in context of source
sourcetzn : timezone used for sourcedt
basetzn: Default timezone used by server
displaytz: Timezone for displaying date
Output:
@displaydt : Date time in context of source
is_DST : set 1 when output is in daylight savings time
Abbreviation: Timezone abbreviation
Offset: GMT offset of displaytzn
*/
SET @sourcetzn = 'America/New_York';
SET @basetzn = 'America/Los_Angeles';
SET @displaytzn = 'America/Chicago';
SET @sourcedt = '2015-07-25 21:33:00';
SET @basedt = CONVERT_TZ(@sourcedt,@sourcetzn,@basetzn);
SET @displaydt = CONVERT_TZ(@basedt,@basetzn, @displaytzn);
SET @utime = unix_timestamp(@basedt);
SELECT
@displaydt,ztt.Abbreviation,ztt.Is_DST,ztt.`Offset`
FROM mysql.`time_zone_name` tzn
JOIN mysql.time_zone_transition_type ztt ON ztt.Time_zone_id=tzn.Time_zone_id
INNER JOIN mysql.time_zone_transition tzt
ON tzt.Time_zone_id = ztt.Time_zone_id
AND tzt.Transition_type_id = ztt.Transition_type_id
where tzn.Name = @displaytzn
and @utime > tzt.Transition_time
order by Transition_time desc
LIMIT 1;