twitter_cldr 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d336c0b6f46b4c7d1f0264115537a6662831e24
4
- data.tar.gz: 832d49c1731724d17b5094e770a69726d0fd5d0c
3
+ metadata.gz: b592fa7bd949a4235c4c700453a4e0a4c3b8b9f3
4
+ data.tar.gz: 125364255f3c0ceab9d3150a0e4b5073235bd563
5
5
  SHA512:
6
- metadata.gz: 7ba318dda353bfdc8bbd5b54800fbdb4099354907dc73c6a8d4afacdc46748c0955535c084cf1e13db0e309b56c2819d3279bd0c6d287373b11bb0098d764929
7
- data.tar.gz: aaad0c5df06f766990b8ec05f590d563dde0e7ee2dd7c7990c0520b1a348fcc2c00c711a8ea634dc1247e29cdfb0e0b29bf7c916587ec0cce9af52507baafaf2
6
+ metadata.gz: d55d1f0467e355b8b7170168ef30e2ae33a034f8d8698c03f713fe41ea9197b188190f4a1cfd74b13ac1e5554daa2f9e3711e93b6c447ec1f2d0c185cf3e73a9
7
+ data.tar.gz: 705b067d1948aa7e1bfcfe4f75c4bc9536f2cc2040fc32f29329235310cc9bc11a1e95754dbb5c47afbc7aea211ebb670cde0a0bbf7f2f20f294ae96431c23b7
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 3.0.9
2
+
3
+ * Fixing date and time formatting issue where calling `to_additional_s` on an instance of `LocalizedDate` could raise an error.
4
+
1
5
  == 3.0.8
2
6
 
3
7
  * Fixing issue causing extraneous single quotes to appear in formatted dates and times.
@@ -46,11 +46,13 @@ module TwitterCldr
46
46
  timezone_info.utc_to_local(time.is_a?(DateTime) ? time.new_offset(0) : time.utc)
47
47
  end
48
48
 
49
- def data_reader_for(type)
50
- TwitterCldr::DataReaders::DateDataReader.new(locale, {
51
- :calendar_type => calendar_type,
52
- :type => type
53
- })
49
+ def data_reader_for(type, options = {})
50
+ TwitterCldr::DataReaders::DateDataReader.new(
51
+ locale, options.merge({
52
+ :calendar_type => calendar_type,
53
+ :type => type
54
+ })
55
+ )
54
56
  end
55
57
 
56
58
  end
@@ -37,7 +37,12 @@ module TwitterCldr
37
37
  :additional_format => additional_format
38
38
  })
39
39
 
40
- tokens = data_reader.tokenizer.full_tokenize(data_reader.pattern)
40
+ tokens = if data_reader.tokenizer.respond_to?(:full_tokenize)
41
+ data_reader.tokenizer.full_tokenize(data_reader.pattern)
42
+ else
43
+ data_reader.tokenizer.tokenize(data_reader.pattern)
44
+ end
45
+
41
46
  data_reader.formatter.format(tokens, base_in_timezone)
42
47
  end
43
48
 
@@ -98,10 +103,12 @@ module TwitterCldr
98
103
  protected
99
104
 
100
105
  def data_reader_for(type, options = {})
101
- TwitterCldr::DataReaders::DateTimeDataReader.new(locale, options.merge({
102
- :calendar_type => calendar_type,
103
- :type => type
104
- }))
106
+ TwitterCldr::DataReaders::DateTimeDataReader.new(
107
+ locale, options.merge({
108
+ :calendar_type => calendar_type,
109
+ :type => type
110
+ })
111
+ )
105
112
  end
106
113
 
107
114
  def chain_params
@@ -35,16 +35,14 @@ module TwitterCldr
35
35
  timezone_info.utc_to_local(@base_obj.utc)
36
36
  end
37
37
 
38
- def data_reader_for(type)
39
- TwitterCldr::DataReaders::TimeDataReader.new(locale, {
40
- :calendar_type => calendar_type,
41
- :type => type
42
- })
38
+ def data_reader_for(type, options = {})
39
+ TwitterCldr::DataReaders::TimeDataReader.new(
40
+ locale, options.merge({
41
+ :calendar_type => calendar_type,
42
+ :type => type
43
+ })
44
+ )
43
45
  end
44
-
45
- # def formatter_const
46
- # TwitterCldr::Formatters::TimeFormatter
47
- # end
48
46
  end
49
47
 
50
48
  end
@@ -4,5 +4,5 @@
4
4
  # http://www.apache.org/licenses/LICENSE-2.0
5
5
 
6
6
  module TwitterCldr
7
- VERSION = "3.0.8"
7
+ VERSION = "3.0.9"
8
8
  end
@@ -120,7 +120,16 @@ describe LocalizedDate do
120
120
  end
121
121
  end
122
122
 
123
- describe 'formatters' do
123
+ describe "#to_additional_s" do
124
+ let(:date_time) { DateTime.new(2010, 7, 6, 12, 12, 30) }
125
+
126
+ it "should format using additional patterns" do
127
+ date = date_time.localize(:en).to_date
128
+ expect(date.to_additional_s("yMMMd")).to eq("Jul 6, 2010")
129
+ end
130
+ end
131
+
132
+ describe "formatters" do
124
133
  it "don't raise errors for any locale" do
125
134
  TwitterCldr.supported_locales.each do |locale|
126
135
  (LocalizedDate.types - [:additional]).each do |type|
@@ -94,6 +94,12 @@ describe LocalizedDateTime do
94
94
  end
95
95
  end
96
96
 
97
+ describe "#to_additional_s" do
98
+ it "should format using additional patterns" do
99
+ expect(date_time.localize(:en).to_additional_s("EHms")).to eq("Sun 22:05:00")
100
+ end
101
+ end
102
+
97
103
  describe "#to_s" do
98
104
  it "uses the default format if no :format is given" do
99
105
  loc_date = date_time.localize
@@ -21,7 +21,7 @@ describe LocalizedTime do
21
21
  it "should stringify with buddhist calendar" do
22
22
  # Ensure that buddhist calendar data is present in th locale.
23
23
  expect(TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist]).not_to(
24
- be_nil, 'buddhist calendar is missing for :th locale (check resources/locales/th/calendars.yml)'
24
+ be_nil, 'buddhist calendar is missing for :th locale (check resources/locales/th/calendars.yml)'
25
25
  )
26
26
 
27
27
  #time.localize(:th, :calendar_type => :buddhist).to_full_s # It doesn't support era
@@ -65,6 +65,13 @@ describe LocalizedTime do
65
65
  end
66
66
  end
67
67
 
68
+ describe "#to_additional_s" do
69
+ it "should format using additional patterns" do
70
+ time = Time.utc(2000, 5, 12, 22, 5)
71
+ expect(time.localize(:es).to_additional_s("Hms")).to eq("22:05:00")
72
+ end
73
+ end
74
+
68
75
  describe "#with_timezone" do
69
76
  it "calculates the right time depending on the timezone" do
70
77
  time = Time.utc(2000, 5, 12, 22, 5).localize
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_cldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.8
4
+ version: 3.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-10 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json