diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-09-29 23:52:51 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-11-12 21:34:54 +0900 |
commit | 81dece54d621c8dd10bb990de487d46a306cedb2 (patch) | |
tree | 1841ad49aa7bb13cb061dff760c463ad6fa58041 /ext | |
parent | d65f1140b94e4817fba4a37efd512c0653a0baf1 (diff) |
[ruby/date] Honor timezones from timeanddate.com
https://github.com/ruby/date/commit/d20380fc55
Diffstat (limited to 'ext')
-rw-r--r-- | ext/date/update-abbr | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/ext/date/update-abbr b/ext/date/update-abbr index e5f6a78c82..7fe9734e6d 100644 --- a/ext/date/update-abbr +++ b/ext/date/update-abbr @@ -2,7 +2,7 @@ require 'nokogiri' require 'open-uri' -doc = Nokogiri::HTML(URI.open('https://www.timeanddate.com/time/zones/')) +doc = Nokogiri::HTML(URI.open(ARGV[0] || 'https://www.timeanddate.com/time/zones/')) h = {} @@ -26,9 +26,26 @@ end h.delete_if{|_,v| !v} lines = File.readlines('zonetab.list') -lines.select{|l| l.include?(',')}. - map{|l| l.split(',', 2)[0]}. - each{|a| h.delete(a)} +lines.map! do |l| + if (sep = /^%%/ =~ l)...(sep = /^%%/ =~ l) and !sep + z, o = l.split(/,\s*/, 2) + o.strip! + if ho = h.delete(z) and ho != eval(o) + warn "offset of #{z}: #{o} -> #{ho}" + l = l.sub(/,\s*\K.*/) { + if o.include?("*") + o1, o2 = ho.abs.divmod(3600) + o1 = "#{o1}*3600" + o1 = "(#{o1}+#{o2})" if o2 != 0 + ho < 0 ? "-#{o1}" : o1 + else + ho.to_s + end + } + end + end + l +end lines.insert(-2, h.sort.map{|k,v| "#{k},#{v}\n"}) lines.flatten! |