twitter_cldr 6.8.0 → 6.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -28
- data/lib/twitter_cldr/resources/calendars_importer.rb +48 -46
- data/lib/twitter_cldr/resources/cldr_data_builder.rb +36 -0
- data/lib/twitter_cldr/resources/cldr_document_set.rb +157 -0
- data/lib/twitter_cldr/resources/cldr_dtd.rb +110 -0
- data/lib/twitter_cldr/resources/cldr_locale.rb +78 -0
- data/lib/twitter_cldr/resources/list_formats_importer.rb +1 -1
- data/lib/twitter_cldr/resources/loader.rb +18 -1
- data/lib/twitter_cldr/resources/number_formats_importer.rb +1 -1
- data/lib/twitter_cldr/resources/readme_renderer.rb +6 -2
- data/lib/twitter_cldr/resources/requirements/cldr_requirement.rb +12 -61
- data/lib/twitter_cldr/resources/territories_importer.rb +1 -1
- data/lib/twitter_cldr/resources/timezones_importer.rb +1 -1
- data/lib/twitter_cldr/resources/unicode_property_aliases_importer.rb +2 -0
- data/lib/twitter_cldr/resources/units_importer.rb +1 -1
- data/lib/twitter_cldr/resources.rb +8 -3
- data/lib/twitter_cldr/shared/calendar.rb +1 -1
- data/lib/twitter_cldr/timezones/generic_location.rb +15 -15
- data/lib/twitter_cldr/timezones/gmt_location.rb +2 -2
- data/lib/twitter_cldr/timezones/iso8601_location.rb +2 -2
- data/lib/twitter_cldr/timezones/timezone.rb +11 -7
- data/lib/twitter_cldr/version.rb +1 -1
- data/resources/locales/ar/calendars.yml +2 -1
- data/resources/locales/az/calendars.yml +2 -1
- data/resources/locales/be/calendars.yml +2 -1
- data/resources/locales/bg/calendars.yml +2 -1
- data/resources/locales/bn/calendars.yml +2 -1
- data/resources/locales/bo/calendars.yml +68 -36
- data/resources/locales/bs/calendars.yml +1 -0
- data/resources/locales/cy/calendars.yml +1 -0
- data/resources/locales/el/calendars.yml +2 -1
- data/resources/locales/en/calendars.yml +75 -54
- data/resources/locales/en-001/calendars.yml +65 -53
- data/resources/locales/en-150/calendars.yml +65 -53
- data/resources/locales/en-AU/calendars.yml +4 -0
- data/resources/locales/en-CA/calendars.yml +66 -58
- data/resources/locales/en-GB/calendars.yml +7 -0
- data/resources/locales/en-IE/calendars.yml +65 -53
- data/resources/locales/en-IN/calendars.yml +65 -53
- data/resources/locales/en-NZ/calendars.yml +65 -53
- data/resources/locales/en-SG/calendars.yml +65 -53
- data/resources/locales/en-US/calendars.yml +75 -54
- data/resources/locales/en-ZA/calendars.yml +65 -53
- data/resources/locales/eo/calendars.yml +88 -61
- data/resources/locales/es/calendars.yml +2 -1
- data/resources/locales/es-419/calendars.yml +2 -1
- data/resources/locales/es-AR/calendars.yml +2 -1
- data/resources/locales/es-CO/calendars.yml +2 -1
- data/resources/locales/es-MX/calendars.yml +2 -1
- data/resources/locales/es-US/calendars.yml +2 -1
- data/resources/locales/fil/calendars.yml +4 -3
- data/resources/locales/ga/calendars.yml +4 -4
- data/resources/locales/gl/calendars.yml +2 -1
- data/resources/locales/hi/calendars.yml +2 -1
- data/resources/locales/hy/calendars.yml +4 -3
- data/resources/locales/ka/calendars.yml +2 -1
- data/resources/locales/kk/calendars.yml +2 -1
- data/resources/locales/km/calendars.yml +2 -1
- data/resources/locales/kn/calendars.yml +2 -1
- data/resources/locales/ko/calendars.yml +2 -1
- data/resources/locales/lo/calendars.yml +2 -1
- data/resources/locales/mk/calendars.yml +1 -1
- data/resources/locales/mr/calendars.yml +2 -1
- data/resources/locales/mt/calendars.yml +2 -1
- data/resources/locales/my/calendars.yml +2 -1
- data/resources/locales/pl/calendars.yml +2 -1
- data/resources/locales/pt/calendars.yml +35 -34
- data/resources/locales/pt-PT/calendars.yml +21 -20
- data/resources/locales/ru/calendars.yml +7 -7
- data/resources/locales/sk/calendars.yml +2 -1
- data/resources/locales/sl/calendars.yml +2 -1
- data/resources/locales/sr/calendars.yml +2 -0
- data/resources/locales/sr-Cyrl-ME/calendars.yml +3 -1
- data/resources/locales/sr-Latn-ME/calendars.yml +3 -1
- data/resources/locales/sw/calendars.yml +2 -1
- data/resources/locales/ta/calendars.yml +2 -1
- data/resources/locales/th/calendars.yml +1 -0
- data/resources/locales/tr/calendars.yml +2 -1
- data/resources/locales/ur/calendars.yml +2 -1
- data/resources/locales/xh/calendars.yml +46 -15
- data/resources/locales/zh-Hant/calendars.yml +4 -4
- data/resources/locales/zu/calendars.yml +3 -1
- data/spec/formatters/calendars/datetime_formatter_spec.rb +2 -2
- data/spec/localized/localized_array_spec.rb +3 -1
- data/spec/localized/localized_hash_spec.rb +1 -1
- data/spec/shared/calendar_spec.rb +25 -8
- data/spec/timezones/timezone_spec.rb +41 -0
- data/spec/utils/yaml/yaml_spec.rb +2 -3
- metadata +7 -3
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
require 'nokogiri'
|
7
|
+
|
8
|
+
module TwitterCldr
|
9
|
+
module Resources
|
10
|
+
|
11
|
+
class CldrLocale
|
12
|
+
attr_reader :base_locale, :cldr_requirement
|
13
|
+
|
14
|
+
def initialize(base_locale, cldr_requirement)
|
15
|
+
@base_locale = base_locale
|
16
|
+
@cldr_requirement = cldr_requirement
|
17
|
+
end
|
18
|
+
|
19
|
+
def ancestors
|
20
|
+
@ancestors ||= [].tap do |ancestry|
|
21
|
+
locale = from_fs(base_locale)
|
22
|
+
ancestry << locale
|
23
|
+
|
24
|
+
loop do
|
25
|
+
cur = from_fs(ancestry.last)
|
26
|
+
|
27
|
+
if parents = parent_locales[cur]
|
28
|
+
ancestry << to_fs(parents)
|
29
|
+
elsif I18n::Locale::Tag.tag(cur).self_and_parents.count > 1
|
30
|
+
ancestry << I18n::Locale::Tag.tag(cur).self_and_parents.last.to_sym
|
31
|
+
else
|
32
|
+
parents = TwitterCldr::Shared::Locale
|
33
|
+
.parse(cur)
|
34
|
+
.permutations
|
35
|
+
.select do |loc|
|
36
|
+
File.exist?(File.join(cldr_requirement.common_path, 'main', "#{loc}.xml"))
|
37
|
+
end
|
38
|
+
|
39
|
+
ancestry.concat(parents - [cur])
|
40
|
+
break
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
ancestry << "root"
|
45
|
+
ancestry.freeze
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def to_fs(locale)
|
52
|
+
locale.to_s.gsub('_', '-').to_sym
|
53
|
+
end
|
54
|
+
|
55
|
+
def from_fs(locale)
|
56
|
+
locale.to_s.gsub('-', '_')
|
57
|
+
end
|
58
|
+
|
59
|
+
def parent_locales
|
60
|
+
@parent_locales ||= supplemental_data.xpath('//parentLocales/parentLocale').each_with_object({}) do |node, ret|
|
61
|
+
parent = node.attr('parent')
|
62
|
+
locales = node.attr('locales').split(' ')
|
63
|
+
|
64
|
+
locales.each do |locale|
|
65
|
+
ret[locale] = parent
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def supplemental_data
|
71
|
+
@supplemental_data ||= Nokogiri.XML(
|
72
|
+
File.read(File.join(cldr_requirement.common_path, 'supplemental', 'supplementalData.xml'))
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -49,7 +49,7 @@ module TwitterCldr
|
|
49
49
|
# locales, we fill in any missing parts at the minor risk of being slightly wrong
|
50
50
|
# when formatting lists. In my opinion, it's far better to produce a slightly wrong
|
51
51
|
# string than to error or produce an entirely empty string.
|
52
|
-
data = requirements[:cldr].
|
52
|
+
data = requirements[:cldr].build_data(locale) do |ancestor_locale|
|
53
53
|
ListFormats.new(ancestor_locale, requirements[:cldr]).to_h
|
54
54
|
end
|
55
55
|
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# Copyright 2012 Twitter, Inc
|
4
4
|
# http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
|
6
|
+
require 'yaml'
|
7
|
+
|
6
8
|
module TwitterCldr
|
7
9
|
module Resources
|
8
10
|
|
@@ -10,7 +12,18 @@ module TwitterCldr
|
|
10
12
|
|
11
13
|
class Loader
|
12
14
|
|
15
|
+
class << self
|
16
|
+
def load_yaml(yaml, permitted_classes: [])
|
17
|
+
if Psych::VERSION >= '4'
|
18
|
+
YAML.safe_load(yaml, permitted_classes: permitted_classes)
|
19
|
+
else
|
20
|
+
YAML.safe_load(yaml, permitted_classes)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
13
25
|
VALID_EXTS = %w(.yml .dump).freeze
|
26
|
+
PERMITTED_YAML_CLASSES = [Range, Regexp, Symbol, Time].freeze
|
14
27
|
|
15
28
|
def get_resource(*path)
|
16
29
|
resources_cache[resource_file_path(path)]
|
@@ -105,7 +118,7 @@ module TwitterCldr
|
|
105
118
|
end
|
106
119
|
|
107
120
|
def load_yaml_resource(path, merge_custom = true)
|
108
|
-
base =
|
121
|
+
base = load_yaml(read_resource_file(path), permitted_classes: PERMITTED_YAML_CLASSES)
|
109
122
|
custom_path = File.join("custom", path)
|
110
123
|
|
111
124
|
if merge_custom && custom_resource_exists?(custom_path) && !TwitterCldr.disable_custom_locale_resources
|
@@ -115,6 +128,10 @@ module TwitterCldr
|
|
115
128
|
base
|
116
129
|
end
|
117
130
|
|
131
|
+
def load_yaml(yaml, permitted_classes: [])
|
132
|
+
self.class.load_yaml(yaml, permitted_classes: permitted_classes)
|
133
|
+
end
|
134
|
+
|
118
135
|
def load_marshalled_resource(path, _merge_custom = :unused)
|
119
136
|
Marshal.load(read_resource_file(path))
|
120
137
|
end
|
@@ -36,7 +36,7 @@ module TwitterCldr
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def import_locale(locale)
|
39
|
-
data = requirements[:cldr].
|
39
|
+
data = requirements[:cldr].build_data(locale) do |ancestor_locale|
|
40
40
|
NumberFormats.new(ancestor_locale, requirements[:cldr]).to_h
|
41
41
|
end
|
42
42
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
# http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
|
6
6
|
require 'erb'
|
7
|
+
require 'yaml'
|
7
8
|
|
8
9
|
module TwitterCldr
|
9
10
|
module Resources
|
@@ -79,8 +80,6 @@ module TwitterCldr
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
82
|
-
private
|
83
|
-
|
84
83
|
def line_num_from_stack_trace(trace)
|
85
84
|
trace[0].split(":")[1].to_i # kind of a hack...
|
86
85
|
end
|
@@ -101,6 +100,11 @@ module TwitterCldr
|
|
101
100
|
ret
|
102
101
|
end
|
103
102
|
end
|
103
|
+
|
104
|
+
def tested_ruby_versions
|
105
|
+
workflow = YAML.load_file(File.join(*%w(.github workflows unit_tests.yml)))
|
106
|
+
workflow["jobs"]["build"]["strategy"]["matrix"]["ruby-version"].join(", ")
|
107
|
+
end
|
104
108
|
end
|
105
109
|
|
106
110
|
end
|
@@ -42,15 +42,6 @@ module TwitterCldr
|
|
42
42
|
File.join(source_path, 'common')
|
43
43
|
end
|
44
44
|
|
45
|
-
def merge_each_ancestor(locale, merge_root: true)
|
46
|
-
locales = locale_chain(locale)
|
47
|
-
locales << :root if merge_root
|
48
|
-
|
49
|
-
locales.inject({}) do |result, ancestor_locale|
|
50
|
-
deep_merge(yield(ancestor_locale), result)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
45
|
def alt?(node)
|
55
46
|
!node.attribute('alt').nil?
|
56
47
|
end
|
@@ -62,49 +53,26 @@ module TwitterCldr
|
|
62
53
|
)
|
63
54
|
end
|
64
55
|
|
65
|
-
|
66
|
-
|
67
|
-
def locale_chain(locale)
|
68
|
-
locale = from_fs(locale)
|
69
|
-
ancestry = [locale]
|
70
|
-
|
71
|
-
loop do
|
72
|
-
cur = from_fs(ancestry.last)
|
73
|
-
|
74
|
-
if parents = parent_locales[cur]
|
75
|
-
ancestry << to_fs(parents)
|
76
|
-
elsif I18n::Locale::Tag.tag(cur).self_and_parents.count > 1
|
77
|
-
ancestry << I18n::Locale::Tag.tag(cur).self_and_parents.last.to_sym
|
78
|
-
else
|
79
|
-
parents = TwitterCldr::Shared::Locale
|
80
|
-
.parse(cur)
|
81
|
-
.permutations
|
82
|
-
.select do |loc|
|
83
|
-
File.exist?(File.join(common_path, 'main', "#{loc}.xml"))
|
84
|
-
end
|
85
|
-
|
86
|
-
ancestry += parents - [cur]
|
87
|
-
break
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
ancestry
|
56
|
+
def build_data(locale, &block)
|
57
|
+
CldrDataBuilder.new(locale_for(locale)).merge_each_ancestor(&block)
|
92
58
|
end
|
93
59
|
|
94
|
-
def
|
95
|
-
|
60
|
+
def docset(path, root_locale)
|
61
|
+
CldrDocumentSet.new(path, locale_for(root_locale), self)
|
96
62
|
end
|
97
63
|
|
98
|
-
def
|
99
|
-
|
64
|
+
def dtd
|
65
|
+
@dtd ||= CldrDTD.new(self)
|
100
66
|
end
|
101
67
|
|
102
|
-
|
103
|
-
|
68
|
+
private
|
69
|
+
|
70
|
+
def locale_for(locale)
|
71
|
+
locales[locale] ||= CldrLocale.new(locale, self)
|
104
72
|
end
|
105
73
|
|
106
|
-
def
|
107
|
-
|
74
|
+
def locales
|
75
|
+
@locales ||= {}
|
108
76
|
end
|
109
77
|
|
110
78
|
def cldr_url
|
@@ -134,23 +102,6 @@ module TwitterCldr
|
|
134
102
|
end
|
135
103
|
end
|
136
104
|
end
|
137
|
-
|
138
|
-
def parent_locales
|
139
|
-
@parent_locales ||= supplemental_data.xpath('//parentLocales/parentLocale').each_with_object({}) do |node, ret|
|
140
|
-
parent = node.attr('parent')
|
141
|
-
locales = node.attr('locales').split(' ')
|
142
|
-
|
143
|
-
locales.each do |locale|
|
144
|
-
ret[locale] = parent
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def supplemental_data
|
150
|
-
@supplemental_data ||= Nokogiri.XML(
|
151
|
-
File.read(File.join(common_path, 'supplemental', 'supplementalData.xml'))
|
152
|
-
)
|
153
|
-
end
|
154
105
|
end
|
155
106
|
|
156
107
|
end
|
@@ -26,7 +26,7 @@ module TwitterCldr
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def import_locale(locale)
|
29
|
-
data = requirements[:cldr].
|
29
|
+
data = requirements[:cldr].build_data(locale) do |ancestor_locale|
|
30
30
|
TerritoryData.new(ancestor_locale, requirements[:cldr]).to_h
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ module TwitterCldr
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def import_locale(locale)
|
41
|
-
data = requirements[:cldr].
|
41
|
+
data = requirements[:cldr].build_data(locale) do |ancestor_locale|
|
42
42
|
TimezoneData.new(ancestor_locale, requirements[:cldr]).to_h
|
43
43
|
end
|
44
44
|
|
@@ -36,7 +36,7 @@ module TwitterCldr
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def import_locale(locale)
|
39
|
-
data = requirements[:cldr].
|
39
|
+
data = requirements[:cldr].build_data(locale) do |ancestor_locale|
|
40
40
|
Units.new(ancestor_locale, requirements[:cldr]).to_h
|
41
41
|
end
|
42
42
|
|
@@ -10,6 +10,10 @@ module TwitterCldr
|
|
10
10
|
autoload :BidiTestImporter, 'twitter_cldr/resources/bidi_test_importer'
|
11
11
|
autoload :CalendarsImporter, 'twitter_cldr/resources/calendars_importer'
|
12
12
|
autoload :CasefolderClassGenerator, 'twitter_cldr/resources/casefolder_class_generator'
|
13
|
+
autoload :CldrDataBuilder, 'twitter_cldr/resources/cldr_data_builder'
|
14
|
+
autoload :CldrDocumentSet, 'twitter_cldr/resources/cldr_document_set'
|
15
|
+
autoload :CldrDTD, 'twitter_cldr/resources/cldr_dtd'
|
16
|
+
autoload :CldrLocale, 'twitter_cldr/resources/cldr_locale'
|
13
17
|
autoload :CollationTestsImporter, 'twitter_cldr/resources/collation_tests_importer'
|
14
18
|
autoload :CollationTriesImporter, 'twitter_cldr/resources/collation_tries_importer'
|
15
19
|
autoload :CurrencySymbolsImporter, 'twitter_cldr/resources/currency_symbols_importer'
|
@@ -25,6 +29,7 @@ module TwitterCldr
|
|
25
29
|
autoload :ParentLocalesImporter, 'twitter_cldr/resources/parent_locales_importer'
|
26
30
|
autoload :PostalCodesImporter, 'twitter_cldr/resources/postal_codes_importer'
|
27
31
|
autoload :Properties, 'twitter_cldr/resources/properties'
|
32
|
+
autoload :ResourceLoadError, 'twitter_cldr/resources/loader'
|
28
33
|
autoload :SegmentDictionariesImporter, 'twitter_cldr/resources/segment_dictionaries_importer'
|
29
34
|
autoload :SegmentRulesImporter, 'twitter_cldr/resources/segment_rules_importer'
|
30
35
|
autoload :SegmentTestsImporter, 'twitter_cldr/resources/segment_tests_importer'
|
@@ -54,6 +59,8 @@ module TwitterCldr
|
|
54
59
|
AliasesImporter,
|
55
60
|
Bcp47TimezoneMetadataImporter,
|
56
61
|
BidiTestImporter,
|
62
|
+
ValidityDataImporter,
|
63
|
+
UnicodePropertyAliasesImporter,
|
57
64
|
CalendarsImporter,
|
58
65
|
CasefolderClassGenerator,
|
59
66
|
CollationTestsImporter,
|
@@ -79,9 +86,7 @@ module TwitterCldr
|
|
79
86
|
TransformTestsImporter,
|
80
87
|
TransformsImporter,
|
81
88
|
UnicodeDataImporter,
|
82
|
-
|
83
|
-
UnitsImporter,
|
84
|
-
ValidityDataImporter,
|
89
|
+
UnitsImporter
|
85
90
|
]
|
86
91
|
end
|
87
92
|
|
@@ -21,18 +21,18 @@ module TwitterCldr
|
|
21
21
|
Territories = TwitterCldr::Shared::Territories
|
22
22
|
Utils = TwitterCldr::Utils
|
23
23
|
|
24
|
-
def display_name_for(date, fmt = :generic_location)
|
24
|
+
def display_name_for(date, fmt = :generic_location, dst = TZInfo::Timezone.default_dst, &block)
|
25
25
|
case fmt
|
26
26
|
when :generic_location
|
27
27
|
generic_location_display_name
|
28
28
|
when :generic_short
|
29
|
-
generic_short_display_name(date) || generic_location_display_name
|
29
|
+
generic_short_display_name(date, dst, &block) || generic_location_display_name
|
30
30
|
when :generic_long
|
31
|
-
generic_long_display_name(date) || generic_location_display_name
|
31
|
+
generic_long_display_name(date, dst, &block) || generic_location_display_name
|
32
32
|
when :specific_short
|
33
|
-
specific_short_display_name(date)
|
33
|
+
specific_short_display_name(date, dst, &block)
|
34
34
|
when :specific_long
|
35
|
-
specific_long_display_name(date)
|
35
|
+
specific_long_display_name(date, dst, &block)
|
36
36
|
when :exemplar_location
|
37
37
|
exemplar_city
|
38
38
|
else
|
@@ -58,20 +58,20 @@ module TwitterCldr
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def generic_short_display_name(date)
|
62
|
-
format_display_name(date, :generic, :short)
|
61
|
+
def generic_short_display_name(date, dst = TZInfo::Timezone.default_dst, &block)
|
62
|
+
format_display_name(date, :generic, :short, dst, &block)
|
63
63
|
end
|
64
64
|
|
65
|
-
def generic_long_display_name(date)
|
66
|
-
format_display_name(date, :generic, :long)
|
65
|
+
def generic_long_display_name(date, dst = TZInfo::Timezone.default_dst, &block)
|
66
|
+
format_display_name(date, :generic, :long, dst, &block)
|
67
67
|
end
|
68
68
|
|
69
|
-
def specific_short_display_name(date)
|
70
|
-
format_display_name(date, :specific, :short)
|
69
|
+
def specific_short_display_name(date, dst = TZInfo::Timezone.default_dst, &block)
|
70
|
+
format_display_name(date, :specific, :short, dst, &block)
|
71
71
|
end
|
72
72
|
|
73
|
-
def specific_long_display_name(date)
|
74
|
-
format_display_name(date, :specific, :long)
|
73
|
+
def specific_long_display_name(date, dst = TZInfo::Timezone.default_dst, &block)
|
74
|
+
format_display_name(date, :specific, :long, dst, &block)
|
75
75
|
end
|
76
76
|
|
77
77
|
# From ICU source, TimeZoneGenericNames.java, formatGenericNonLocationName():
|
@@ -86,9 +86,9 @@ module TwitterCldr
|
|
86
86
|
# 4. If a generic non-location string is not available, use generic location
|
87
87
|
# string.
|
88
88
|
#
|
89
|
-
def format_display_name(date, type, fmt)
|
89
|
+
def format_display_name(date, type, fmt, dst = TZInfo::Timezone.default_dst, &block)
|
90
90
|
date_int = date.strftime('%s').to_i
|
91
|
-
period = tz.period_for_local(date)
|
91
|
+
period = tz.period_for_local(date, dst, &block)
|
92
92
|
|
93
93
|
flavor = if type == :generic
|
94
94
|
:generic
|
@@ -10,8 +10,8 @@ module TwitterCldr
|
|
10
10
|
DEFAULT_FORMAT = :long_gmt
|
11
11
|
DEFAULT_GMT_ZERO_FORMAT = 'GMT'.freeze
|
12
12
|
|
13
|
-
def display_name_for(date, format = DEFAULT_FORMAT)
|
14
|
-
offset = tz.period_for_local(date).offset
|
13
|
+
def display_name_for(date, format = DEFAULT_FORMAT, dst = TZInfo::Timezone.default_dst, &block)
|
14
|
+
offset = tz.period_for_local(date, dst, &block).offset
|
15
15
|
offset_secs = offset.utc_offset + offset.std_offset
|
16
16
|
return gmt_zero_format if offset_secs == 0
|
17
17
|
|
@@ -27,8 +27,8 @@ module TwitterCldr
|
|
27
27
|
:iso_extended_local_full
|
28
28
|
].freeze
|
29
29
|
|
30
|
-
def display_name_for(date, fmt)
|
31
|
-
offset = tz.period_for_local(date).offset
|
30
|
+
def display_name_for(date, fmt, dst = TZInfo::Timezone.default_dst, &block)
|
31
|
+
offset = tz.period_for_local(date, dst, &block).offset
|
32
32
|
offset_secs = offset.utc_offset + offset.std_offset
|
33
33
|
|
34
34
|
case fmt
|
@@ -47,17 +47,17 @@ module TwitterCldr
|
|
47
47
|
@locale = locale
|
48
48
|
end
|
49
49
|
|
50
|
-
def display_name_for(date, format = :generic_location)
|
50
|
+
def display_name_for(date, format = :generic_location, dst = TZInfo::Timezone.default_dst, &block)
|
51
51
|
case format
|
52
52
|
when *GenericLocation::FORMATS
|
53
|
-
generic_location.display_name_for(date, format) ||
|
54
|
-
gmt_location.display_name_for(date, GENERIC_TO_GMT_MAP[format])
|
53
|
+
generic_location.display_name_for(date, format, dst, &block) ||
|
54
|
+
gmt_location.display_name_for(date, GENERIC_TO_GMT_MAP[format], dst, &block)
|
55
55
|
|
56
56
|
when *GmtLocation::FORMATS
|
57
|
-
gmt_location.display_name_for(date, format)
|
57
|
+
gmt_location.display_name_for(date, format, dst, &block)
|
58
58
|
|
59
59
|
when *Iso8601Location::FORMATS
|
60
|
-
iso_location.display_name_for(date, format)
|
60
|
+
iso_location.display_name_for(date, format, dst, &block)
|
61
61
|
|
62
62
|
when :zone_id
|
63
63
|
identifier
|
@@ -75,8 +75,12 @@ module TwitterCldr
|
|
75
75
|
tz.identifier
|
76
76
|
end
|
77
77
|
|
78
|
-
def period_for_local(
|
79
|
-
tz.period_for_local(
|
78
|
+
def period_for_local(*args, &block)
|
79
|
+
tz.period_for_local(*args, &block)
|
80
|
+
end
|
81
|
+
|
82
|
+
def period_for_utc(time)
|
83
|
+
tz.period_for_utc(time)
|
80
84
|
end
|
81
85
|
|
82
86
|
def transitions_up_to(date)
|
data/lib/twitter_cldr/version.rb
CHANGED