From 81dece54d621c8dd10bb990de487d46a306cedb2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 29 Sep 2020 23:52:51 +0900 Subject: [ruby/date] Honor timezones from timeanddate.com https://github.com/ruby/date/commit/d20380fc55 --- ext/date/update-abbr | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'ext') 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! -- cgit v1.2.3