Created
November 13, 2013 12:33
-
-
Save joshz/7448346 to your computer and use it in GitHub Desktop.
timezonedb in sqlite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DATETIME(1379478541.13277 + tz.gmt_offset, 'unixepoch', 'localtime') AS local_time, z.country_code, z.zone_name, tz.abbreviation | |
FROM timezone tz JOIN zone z | |
ON tz.zone_id=z.zone_id | |
WHERE tz.time_start < 1379478541.13277 AND z.zone_name='Europe/Warsaw' | |
ORDER BY tz.time_start DESC LIMIT 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS 'country'; | |
CREATE TABLE 'country' ( | |
'country_code' CHAR(2) NULL COLLATE BINARY, | |
'country_name' VARCHAR(45) NULL | |
); | |
CREATE INDEX idx_country_code ON country(country_code); | |
DROP TABLE IF EXISTS 'timezone'; | |
CREATE TABLE 'timezone' ( | |
'zone_id' INT(10) NOT NULL COLLATE BINARY, | |
'abbreviation' VARCHAR(6) NOT NULL COLLATE BINARY, | |
'time_start' INT NOT NULL COLLATE BINARY, | |
'gmt_offset' INT NOT NULL, | |
'dst' CHAR(1) NOT NULL | |
); | |
CREATE INDEX idx_zone_id ON timezone(zone_id); | |
CREATE INDEX idx_time_start ON timezone(time_start); | |
DROP TABLE IF EXISTS 'zone'; | |
CREATE TABLE 'zone' ( | |
'zone_id' INTEGER PRIMARY KEY COLLATE BINARY, | |
'country_code' CHAR(2) NOT NULL, | |
'zone_name' VARCHAR(35) NOT NULL | |
); | |
CREATE INDEX idx_zone_name ON zone(zone_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment