[ruby/date] Add more timezone abbreviations

This gets the time zone abbreviations from
https://www.timeanddate.com/time/zones/, and adds unambiguous time
zones not already present in zonetab.list.  See bin/update-abbr
for the program used.

This regenerates zonetab.h using prereq.mk (requires gperf).

Only one test line is added, just to make sure a new time zone
abbreviation is picked up.

Fixes Ruby Bug 16286

https://github.com/ruby/date/commit/702e8b3033
This commit is contained in:
Jeremy Evans 2019-10-31 11:29:37 -07:00 коммит произвёл Nobuyoshi Nakada
Родитель 51825c04db
Коммит 469545307f
4 изменённых файлов: 1553 добавлений и 746 удалений

35
bin/update-abbr Normal file
Просмотреть файл

@ -0,0 +1,35 @@
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(URI.open('https://www.timeanddate.com/time/zones/'))
h = {}
doc.css('#tz-abb tbody tr').each do |tr|
tds = tr.css('td')
abbr = tds[0].text.strip.downcase
offset = tds[3].text.strip.gsub(/UTC\s*/, '')
next if offset.include?('/') # skip ambiguous timezones
next if offset.empty?
hour, min = offset.split(':', 2)
offset = (Integer(hour) * 60 + (Integer(min || 0)))*60
if h.has_key?(abbr)
h[abbr] = false
else
h[abbr] = offset
end
end
h.delete_if{|_,v| !v}
lines = File.readlines('ext/date/zonetab.list')
lines.select{|l| l.include?(',')}.
map{|l| l.split(',', 2)[0]}.
each{|a| h.delete(a)}
h.sort.map{|k,v| "#{k},#{v}"}
lines.insert(-2, h.sort.map{|k,v| "#{k},#{v}\n"})
lines.flatten!
File.write('ext/date/zonetab.list', lines.join)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -178,4 +178,150 @@ w. europe, 3600
west asia, 18000
west pacific, 36000
yakutsk, 32400
acdt,37800
acst,34200
act,-18000
acwst,31500
aedt,39600
aest,36000
aft,16200
almt,21600
anast,43200
anat,43200
aoe,-43200
aqtt,18000
awdt,32400
awst,28800
azost,0
azot,-3600
azst,18000
azt,14400
bnt,28800
bot,-14400
btt,21600
cast,28800
chadt,49500
chast,45900
chost,32400
chot,28800
chst,36000
chut,36000
cidst,-14400
cist,-18000
ckt,-36000
cot,-18000
cvt,-3600
cxt,25200
davt,25200
ddut,36000
easst,-18000
ect,-18000
egst,0
egt,-3600
fet,10800
fjst,46800
fjt,43200
fkst,-10800
fkt,-14400
fnt,-7200
galt,-21600
gamt,-32400
get,14400
gft,-10800
gilt,43200
gyt,-14400
hkt,28800
hovst,28800
hovt,25200
ict,25200
idt,10800
iot,21600
irdt,16200
irkst,32400
irkt,28800
irst,12600
kgt,21600
kost,39600
krast,28800
krat,25200
kuyt,14400
lhdt,39600
lhst,37800
lint,50400
magst,43200
magt,39600
mart,-30600
mawt,18000
mht,43200
mmt,23400
mut,14400
mvt,18000
myt,28800
nct,39600
nfdt,43200
nft,39600
novst,25200
novt,25200
npt,20700
nrt,43200
nut,-39600
omsst,25200
omst,21600
orat,18000
pet,-18000
petst,43200
pett,43200
pgt,36000
phot,46800
pht,28800
pkt,18000
pmdt,-7200
pmst,-10800
pont,39600
pwt,32400
pyst,-10800
qyzt,21600
ret,14400
rott,-10800
sakt,39600
samt,14400
sbt,39600
sct,14400
sret,39600
srt,-10800
syot,10800
taht,-36000
tft,18000
tjt,18000
tkt,46800
tlt,32400
tmt,18000
tost,50400
tot,46800
trt,10800
tvt,43200
ulast,32400
ulat,28800
uyst,-7200
uyt,-10800
uzt,18000
vet,-14400
vlast,39600
vlat,36000
vost,21600
vut,39600
wakt,43200
warst,-10800
wft,43200
wgst,-7200
wgt,-10800
wib,25200
wit,32400
wita,28800
wt,0
yakst,36000
yakt,32400
yapt,36000
yekst,21600
yekt,18000
%%

Просмотреть файл

@ -24,6 +24,7 @@ class TestDateParse < Test::Unit::TestCase
[['Sat Aug 28 02:29:34 JST 02',true],[2002,8,28,2,29,34,'JST',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 JST 0002',false],[2,8,28,2,29,34,'JST',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 JST 0002',true],[2,8,28,2,29,34,'JST',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 AEST 0002',true],[2,8,28,2,29,34,'AEST',10*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 GMT+09 0002',false],[2,8,28,2,29,34,'GMT+09',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 GMT+0900 0002',false],[2,8,28,2,29,34,'GMT+0900',9*3600,6], __LINE__],