ruby-cldr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -0
- data/Gemfile.lock +23 -0
- data/README.textile +9 -6
- data/VERSION +1 -1
- data/lib/cldr.rb +1 -1
- data/lib/cldr/data.rb +9 -29
- data/lib/cldr/download.rb +2 -2
- data/lib/cldr/export.rb +8 -2
- data/lib/cldr/export/code.rb +34 -0
- data/lib/cldr/export/code/numbers.rb +29 -0
- data/lib/cldr/export/data.rb +36 -0
- data/lib/cldr/export/data/base.rb +61 -0
- data/lib/cldr/export/data/calendars.rb +14 -0
- data/lib/cldr/export/data/calendars/gregorian.rb +142 -0
- data/lib/cldr/export/data/currencies.rb +28 -0
- data/lib/cldr/export/data/delimiters.rb +29 -0
- data/lib/cldr/export/data/languages.rb +19 -0
- data/lib/cldr/export/data/numbers.rb +67 -0
- data/lib/cldr/export/data/plurals.rb +41 -0
- data/lib/cldr/{data → export/data}/plurals/cldr_grammar.treetop +0 -0
- data/lib/cldr/export/data/plurals/grammar.rb +538 -0
- data/lib/cldr/export/data/plurals/rules.rb +119 -0
- data/lib/cldr/export/data/territories.rb +19 -0
- data/lib/cldr/export/data/timezones.rb +27 -0
- data/lib/cldr/export/data/units.rb +29 -0
- data/lib/cldr/export/ruby.rb +1 -1
- data/lib/cldr/export/yaml.rb +1 -1
- data/lib/cldr/format.rb +1 -97
- data/lib/cldr/format/currency.rb +1 -1
- data/lib/cldr/format/date.rb +1 -1
- data/lib/cldr/format/datetime.rb +14 -18
- data/lib/cldr/format/datetime/base.rb +1 -1
- data/lib/cldr/format/decimal.rb +1 -1
- data/lib/cldr/format/decimal/base.rb +1 -1
- data/lib/cldr/format/decimal/fraction.rb +1 -1
- data/lib/cldr/format/decimal/integer.rb +1 -1
- data/lib/cldr/format/decimal/number.rb +1 -1
- data/lib/cldr/format/percent.rb +1 -1
- data/lib/cldr/format/time.rb +1 -1
- data/lib/cldr/thor.rb +3 -3
- data/test/all.rb +1 -1
- data/test/export/code/numbers_test.rb +11 -0
- data/test/{data → export/data}/all.rb +1 -1
- data/test/{data → export/data}/calendars_test.rb +18 -18
- data/test/{data → export/data}/currencies_test.rb +6 -6
- data/test/{data → export/data}/delimiters_test.rb +6 -6
- data/test/{data → export/data}/languages_test.rb +6 -6
- data/test/{data → export/data}/numbers_test.rb +8 -8
- data/test/export/data/plurals_test.rb +141 -0
- data/test/{data → export/data}/territories_test.rb +6 -6
- data/test/{data → export/data}/timezones_test.rb +6 -6
- data/test/{data → export/data}/units_test.rb +6 -6
- data/test/export_test.rb +8 -8
- data/test/{formats → format}/all.rb +1 -1
- data/test/format/currency_test.rb +0 -0
- data/test/format/date_test.rb +265 -0
- data/test/format/datetime_test.rb +18 -0
- data/test/{formats → format}/decimal/fraction_test.rb +4 -4
- data/test/{formats → format}/decimal/integer_test.rb +17 -17
- data/test/{formats → format}/decimal/number_test.rb +19 -19
- data/test/{formats → format}/decimal_test.rb +5 -5
- data/test/format/percent_test.rb +0 -0
- data/test/format/time_test.rb +195 -0
- data/test/test_autotest.rb +36 -0
- data/test/test_helper.rb +16 -1
- metadata +124 -114
- data/lib/cldr/data/base.rb +0 -66
- data/lib/cldr/data/calendars.rb +0 -12
- data/lib/cldr/data/calendars/gregorian.rb +0 -124
- data/lib/cldr/data/currencies.rb +0 -26
- data/lib/cldr/data/delimiters.rb +0 -21
- data/lib/cldr/data/languages.rb +0 -17
- data/lib/cldr/data/numbers.rb +0 -60
- data/lib/cldr/data/plurals.rb +0 -39
- data/lib/cldr/data/plurals/grammar.rb +0 -536
- data/lib/cldr/data/plurals/rules.rb +0 -113
- data/lib/cldr/data/territories.rb +0 -17
- data/lib/cldr/data/timezones.rb +0 -25
- data/lib/cldr/data/units.rb +0 -25
- data/test/data/plurals_test.rb +0 -132
- data/test/formats/datetime/all.rb +0 -3
- data/test/formats/datetime/date_test.rb +0 -31
- data/test/formats/datetime/datetime_test.rb +0 -18
- data/test/formats/datetime/day_test.rb +0 -41
- data/test/formats/datetime/hour_test.rb +0 -79
- data/test/formats/datetime/minute_test.rb +0 -25
- data/test/formats/datetime/month_test.rb +0 -76
- data/test/formats/datetime/period_test.rb +0 -20
- data/test/formats/datetime/quarter_test.rb +0 -118
- data/test/formats/datetime/second_test.rb +0 -80
- data/test/formats/datetime/time_test.rb +0 -33
- data/test/formats/datetime/timezone_test.rb +0 -23
- data/test/formats/datetime/year_test.rb +0 -57
- data/test/formats/format_test.rb +0 -66
- data/test/formats/rails_compat/all.rb +0 -3
- data/test/formats/rails_compat/format_integer_test.rb +0 -56
- data/test/formats/rails_compat/format_number_test.rb +0 -134
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateMinuteFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "test: m" do
|
17
|
-
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'm')
|
18
|
-
assert_equal '11', format(Time.local(2000, 1, 1, 1, 11, 1), 'm')
|
19
|
-
end
|
20
|
-
|
21
|
-
define_method "test: mm" do
|
22
|
-
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'mm')
|
23
|
-
assert_equal '11', format(Time.local(2000, 1, 1, 1, 11, 1), 'mm')
|
24
|
-
end
|
25
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateMonthFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Date.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
# MONTH
|
17
|
-
|
18
|
-
define_method "test: pattern M" do
|
19
|
-
assert_equal '1', format(Date.new(2010, 1, 1), 'M')
|
20
|
-
assert_equal '10', format(Date.new(2010, 10, 1), 'M')
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method "test: pattern MM" do
|
24
|
-
assert_equal '01', format(Date.new(2010, 1, 1), 'MM')
|
25
|
-
assert_equal '10', format(Date.new(2010, 10, 1), 'MM')
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method "test: pattern MMM" do
|
29
|
-
assert_equal 'Jan', format(Date.new(2010, 1, 1), 'MMM')
|
30
|
-
assert_equal 'Okt', format(Date.new(2010, 10, 1), 'MMM')
|
31
|
-
end
|
32
|
-
|
33
|
-
define_method "test: pattern MMMM" do
|
34
|
-
assert_equal 'Januar', format(Date.new(2010, 1, 1), 'MMMM')
|
35
|
-
assert_equal 'Oktober', format(Date.new(2010, 10, 1), 'MMMM')
|
36
|
-
end
|
37
|
-
|
38
|
-
# requires cldr's "multiple inheritance"
|
39
|
-
#
|
40
|
-
# define_method "test: pattern MMMMM" do
|
41
|
-
# assert_equal 'J', format(Date.new(2010, 1, 1), 'MMMMM')
|
42
|
-
# assert_equal 'O', format(Date.new(2010, 10, 1), 'MMMMM')
|
43
|
-
# end
|
44
|
-
|
45
|
-
define_method "test: pattern L" do
|
46
|
-
assert_equal '1', format(Date.new(2010, 1, 1), 'L')
|
47
|
-
assert_equal '10', format(Date.new(2010, 10, 1), 'L')
|
48
|
-
end
|
49
|
-
|
50
|
-
define_method "test: pattern LL" do
|
51
|
-
assert_equal '01', format(Date.new(2010, 1, 1), 'LL')
|
52
|
-
assert_equal '10', format(Date.new(2010, 10, 1), 'LL')
|
53
|
-
end
|
54
|
-
|
55
|
-
# requires cldr's "multiple inheritance"
|
56
|
-
#
|
57
|
-
# define_method "test: pattern LLL" do
|
58
|
-
# assert_equal 'Jan', format(Date.new(2010, 1, 1), 'LLL')
|
59
|
-
# assert_equal 'Okt', format(Date.new(2010, 10, 1), 'LLL')
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# define_method "test: pattern LLLL" do
|
63
|
-
# assert_equal 'Januar', format(Date.new(2010, 1, 1), 'LLLL')
|
64
|
-
# assert_equal 'Oktober', format(Date.new(2010, 10, 1), 'LLLL')
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# define_method "test: pattern LLLLL" do
|
68
|
-
# assert_equal 'J', format(Date.new(2010, 1, 1), 'LLLLL')
|
69
|
-
# assert_equal 'O', format(Date.new(2010, 10, 1), 'LLLLL')
|
70
|
-
# end
|
71
|
-
|
72
|
-
define_method "test: pattern LLLLL" do
|
73
|
-
assert_equal 'J', format(Date.new(2010, 1, 1), 'LLLLL')
|
74
|
-
assert_equal 'O', format(Date.new(2010, 10, 1), 'LLLLL')
|
75
|
-
end
|
76
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDatePeriodFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "test: a" do
|
17
|
-
assert_equal 'vorm.', format(Time.local(2000, 1, 1, 1, 1, 1), 'a')
|
18
|
-
assert_equal 'nachm.', format(Time.local(2000, 1, 1, 15, 1, 1), 'a')
|
19
|
-
end
|
20
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateQuarterFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Date.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
# QUARTER
|
17
|
-
|
18
|
-
define_method "test: pattern Q" do
|
19
|
-
assert_equal '1', format(Date.new(2010, 1, 1), 'Q')
|
20
|
-
assert_equal '1', format(Date.new(2010, 3, 31), 'Q')
|
21
|
-
assert_equal '2', format(Date.new(2010, 4, 1), 'Q')
|
22
|
-
assert_equal '2', format(Date.new(2010, 6, 30), 'Q')
|
23
|
-
assert_equal '3', format(Date.new(2010, 7, 1), 'Q')
|
24
|
-
assert_equal '3', format(Date.new(2010, 9, 30), 'Q')
|
25
|
-
assert_equal '4', format(Date.new(2010, 10, 1), 'Q')
|
26
|
-
assert_equal '4', format(Date.new(2010, 12, 31), 'Q')
|
27
|
-
end
|
28
|
-
|
29
|
-
define_method "test: pattern QQ" do
|
30
|
-
assert_equal '01', format(Date.new(2010, 1, 1), 'QQ')
|
31
|
-
assert_equal '01', format(Date.new(2010, 3, 31), 'QQ')
|
32
|
-
assert_equal '02', format(Date.new(2010, 4, 1), 'QQ')
|
33
|
-
assert_equal '02', format(Date.new(2010, 6, 30), 'QQ')
|
34
|
-
assert_equal '03', format(Date.new(2010, 7, 1), 'QQ')
|
35
|
-
assert_equal '03', format(Date.new(2010, 9, 30), 'QQ')
|
36
|
-
assert_equal '04', format(Date.new(2010, 10, 1), 'QQ')
|
37
|
-
assert_equal '04', format(Date.new(2010, 12, 31), 'QQ')
|
38
|
-
end
|
39
|
-
|
40
|
-
define_method "test: pattern QQQ" do
|
41
|
-
assert_equal 'Q1', format(Date.new(2010, 1, 1), 'QQQ')
|
42
|
-
assert_equal 'Q1', format(Date.new(2010, 3, 31), 'QQQ')
|
43
|
-
assert_equal 'Q2', format(Date.new(2010, 4, 1), 'QQQ')
|
44
|
-
assert_equal 'Q2', format(Date.new(2010, 6, 30), 'QQQ')
|
45
|
-
assert_equal 'Q3', format(Date.new(2010, 7, 1), 'QQQ')
|
46
|
-
assert_equal 'Q3', format(Date.new(2010, 9, 30), 'QQQ')
|
47
|
-
assert_equal 'Q4', format(Date.new(2010, 10, 1), 'QQQ')
|
48
|
-
assert_equal 'Q4', format(Date.new(2010, 12, 31), 'QQQ')
|
49
|
-
end
|
50
|
-
|
51
|
-
define_method "test: pattern QQQQ" do
|
52
|
-
assert_equal '1. Quartal', format(Date.new(2010, 1, 1), 'QQQQ')
|
53
|
-
assert_equal '1. Quartal', format(Date.new(2010, 3, 31), 'QQQQ')
|
54
|
-
assert_equal '2. Quartal', format(Date.new(2010, 4, 1), 'QQQQ')
|
55
|
-
assert_equal '2. Quartal', format(Date.new(2010, 6, 30), 'QQQQ')
|
56
|
-
assert_equal '3. Quartal', format(Date.new(2010, 7, 1), 'QQQQ')
|
57
|
-
assert_equal '3. Quartal', format(Date.new(2010, 9, 30), 'QQQQ')
|
58
|
-
assert_equal '4. Quartal', format(Date.new(2010, 10, 1), 'QQQQ')
|
59
|
-
assert_equal '4. Quartal', format(Date.new(2010, 12, 31), 'QQQQ')
|
60
|
-
end
|
61
|
-
|
62
|
-
define_method "test: pattern q" do
|
63
|
-
assert_equal '1', format(Date.new(2010, 1, 1), 'q')
|
64
|
-
assert_equal '1', format(Date.new(2010, 3, 31), 'q')
|
65
|
-
assert_equal '2', format(Date.new(2010, 4, 1), 'q')
|
66
|
-
assert_equal '2', format(Date.new(2010, 6, 30), 'q')
|
67
|
-
assert_equal '3', format(Date.new(2010, 7, 1), 'q')
|
68
|
-
assert_equal '3', format(Date.new(2010, 9, 30), 'q')
|
69
|
-
assert_equal '4', format(Date.new(2010, 10, 1), 'q')
|
70
|
-
assert_equal '4', format(Date.new(2010, 12, 31), 'q')
|
71
|
-
end
|
72
|
-
|
73
|
-
define_method "test: pattern qq" do
|
74
|
-
assert_equal '01', format(Date.new(2010, 1, 1), 'qq')
|
75
|
-
assert_equal '01', format(Date.new(2010, 3, 31), 'qq')
|
76
|
-
assert_equal '02', format(Date.new(2010, 4, 1), 'qq')
|
77
|
-
assert_equal '02', format(Date.new(2010, 6, 30), 'qq')
|
78
|
-
assert_equal '03', format(Date.new(2010, 7, 1), 'qq')
|
79
|
-
assert_equal '03', format(Date.new(2010, 9, 30), 'qq')
|
80
|
-
assert_equal '04', format(Date.new(2010, 10, 1), 'qq')
|
81
|
-
assert_equal '04', format(Date.new(2010, 12, 31), 'qq')
|
82
|
-
end
|
83
|
-
|
84
|
-
# requires "multiple inheritance"
|
85
|
-
#
|
86
|
-
# define_method "test: pattern qqq" do
|
87
|
-
# assert_equal 'Q1', format(Date.new(2010, 1, 1), 'qqq')
|
88
|
-
# assert_equal 'Q1', format(Date.new(2010, 3, 31), 'qqq')
|
89
|
-
# assert_equal 'Q2', format(Date.new(2010, 4, 1), 'qqq')
|
90
|
-
# assert_equal 'Q2', format(Date.new(2010, 6, 30), 'qqq')
|
91
|
-
# assert_equal 'Q3', format(Date.new(2010, 7, 1), 'qqq')
|
92
|
-
# assert_equal 'Q3', format(Date.new(2010, 9, 30), 'qqq')
|
93
|
-
# assert_equal 'Q4', format(Date.new(2010, 10, 1), 'qqq')
|
94
|
-
# assert_equal 'Q4', format(Date.new(2010, 12, 31), 'qqq')
|
95
|
-
# end
|
96
|
-
#
|
97
|
-
# define_method "test: pattern qqqq" do
|
98
|
-
# assert_equal '1. Quartal', format(Date.new(2010, 1, 1), 'qqqq')
|
99
|
-
# assert_equal '1. Quartal', format(Date.new(2010, 3, 31), 'qqqq')
|
100
|
-
# assert_equal '2. Quartal', format(Date.new(2010, 4, 1), 'qqqq')
|
101
|
-
# assert_equal '2. Quartal', format(Date.new(2010, 6, 30), 'qqqq')
|
102
|
-
# assert_equal '3. Quartal', format(Date.new(2010, 7, 1), 'qqqq')
|
103
|
-
# assert_equal '3. Quartal', format(Date.new(2010, 9, 30), 'qqqq')
|
104
|
-
# assert_equal '4. Quartal', format(Date.new(2010, 10, 1), 'qqqq')
|
105
|
-
# assert_equal '4. Quartal', format(Date.new(2010, 12, 31), 'qqqq')
|
106
|
-
# end
|
107
|
-
|
108
|
-
define_method "test: pattern qqqqq" do
|
109
|
-
assert_equal '1', format(Date.new(2010, 1, 1), 'qqqqq')
|
110
|
-
assert_equal '1', format(Date.new(2010, 3, 31), 'qqqqq')
|
111
|
-
assert_equal '2', format(Date.new(2010, 4, 1), 'qqqqq')
|
112
|
-
assert_equal '2', format(Date.new(2010, 6, 30), 'qqqqq')
|
113
|
-
assert_equal '3', format(Date.new(2010, 7, 1), 'qqqqq')
|
114
|
-
assert_equal '3', format(Date.new(2010, 9, 30), 'qqqqq')
|
115
|
-
assert_equal '4', format(Date.new(2010, 10, 1), 'qqqqq')
|
116
|
-
assert_equal '4', format(Date.new(2010, 12, 31), 'qqqqq')
|
117
|
-
end
|
118
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateSecondFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "test: s" do
|
17
|
-
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 's')
|
18
|
-
assert_equal '11', format(Time.local(2000, 1, 1, 1, 1, 11), 's')
|
19
|
-
end
|
20
|
-
|
21
|
-
define_method "test: ss" do
|
22
|
-
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'ss')
|
23
|
-
assert_equal '11', format(Time.local(2000, 1, 1, 1, 1, 11), 'ss')
|
24
|
-
end
|
25
|
-
|
26
|
-
# have i gotten the spec right here?
|
27
|
-
define_method "test: S" do
|
28
|
-
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'S')
|
29
|
-
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'S')
|
30
|
-
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'S')
|
31
|
-
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'S')
|
32
|
-
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'S')
|
33
|
-
assert_equal '8', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'S')
|
34
|
-
end
|
35
|
-
|
36
|
-
define_method "test: SS" do
|
37
|
-
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SS')
|
38
|
-
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SS')
|
39
|
-
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SS')
|
40
|
-
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SS')
|
41
|
-
assert_equal '08', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SS')
|
42
|
-
assert_equal '78', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SS')
|
43
|
-
end
|
44
|
-
|
45
|
-
define_method "test: SSS" do
|
46
|
-
assert_equal '000', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSS')
|
47
|
-
assert_equal '000', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSS')
|
48
|
-
assert_equal '001', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSS')
|
49
|
-
assert_equal '008', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSS')
|
50
|
-
assert_equal '078', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSS')
|
51
|
-
assert_equal '778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSS')
|
52
|
-
end
|
53
|
-
|
54
|
-
define_method "test: SSSS" do
|
55
|
-
assert_equal '0000', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSS')
|
56
|
-
assert_equal '0001', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSS')
|
57
|
-
assert_equal '0008', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSS')
|
58
|
-
assert_equal '0078', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSS')
|
59
|
-
assert_equal '0778', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSS')
|
60
|
-
assert_equal '7778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSS')
|
61
|
-
end
|
62
|
-
|
63
|
-
define_method "test: SSSSS" do
|
64
|
-
assert_equal '00001', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSSS')
|
65
|
-
assert_equal '00008', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSSS')
|
66
|
-
assert_equal '00078', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSSS')
|
67
|
-
assert_equal '00778', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSSS')
|
68
|
-
assert_equal '07778', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSSS')
|
69
|
-
assert_equal '77778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSSS')
|
70
|
-
end
|
71
|
-
|
72
|
-
define_method "test: SSSSSS" do
|
73
|
-
assert_equal '000007', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSSSS')
|
74
|
-
assert_equal '000077', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSSSS')
|
75
|
-
assert_equal '000777', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSSSS')
|
76
|
-
assert_equal '007777', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSSSS')
|
77
|
-
assert_equal '077777', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSSSS')
|
78
|
-
assert_equal '777777', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSSSS')
|
79
|
-
end
|
80
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateTimeFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Timezone missing
|
17
|
-
#
|
18
|
-
# define_method "test: full time pattern :de" do
|
19
|
-
# assert_equal '13:12:11 zzzz', format(Time.local(2000, 1, 1, 13, 12, 11), 'HH:mm:ss zzzz')
|
20
|
-
# end
|
21
|
-
|
22
|
-
define_method "test: long time pattern :de" do
|
23
|
-
assert_equal '13:12:11 UTC', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm:ss z')
|
24
|
-
end
|
25
|
-
|
26
|
-
define_method "test: medium time pattern :de" do
|
27
|
-
assert_equal '13:12:11', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm:ss')
|
28
|
-
end
|
29
|
-
|
30
|
-
define_method "test: short time pattern :de" do
|
31
|
-
assert_equal '13:12', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm')
|
32
|
-
end
|
33
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateTimezoneFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
# TIMEZONE
|
17
|
-
|
18
|
-
define_method "test: z, zz, zzz" do # TODO is this what's meant by the spec?
|
19
|
-
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'z')
|
20
|
-
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'zz')
|
21
|
-
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'zzz')
|
22
|
-
end
|
23
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
class TestCldrDateYearFormat < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@locale = :de
|
9
|
-
@calendar = Cldr::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(object, pattern)
|
13
|
-
Cldr::Format::Date.new(pattern, @calendar).apply(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
# YEAR
|
17
|
-
|
18
|
-
define_method "test: pattern y" do
|
19
|
-
assert_equal '5', format(Date.new( 5, 1, 1), 'y')
|
20
|
-
assert_equal '45', format(Date.new( 45, 1, 1), 'y')
|
21
|
-
assert_equal '345', format(Date.new( 345, 1, 1), 'y')
|
22
|
-
assert_equal '2345', format(Date.new( 2345, 1, 1), 'y')
|
23
|
-
assert_equal '12345', format(Date.new(12345, 1, 1), 'y')
|
24
|
-
end
|
25
|
-
|
26
|
-
define_method "test: pattern yy" do
|
27
|
-
assert_equal '05', format(Date.new( 5, 1, 1), 'yy')
|
28
|
-
assert_equal '45', format(Date.new( 45, 1, 1), 'yy')
|
29
|
-
assert_equal '45', format(Date.new( 345, 1, 1), 'yy')
|
30
|
-
assert_equal '45', format(Date.new( 2345, 1, 1), 'yy')
|
31
|
-
assert_equal '45', format(Date.new(12345, 1, 1), 'yy')
|
32
|
-
end
|
33
|
-
|
34
|
-
define_method "test: pattern yyy" do
|
35
|
-
assert_equal '005', format(Date.new( 5, 1, 1), 'yyy')
|
36
|
-
assert_equal '045', format(Date.new( 45, 1, 1), 'yyy')
|
37
|
-
assert_equal '345', format(Date.new( 345, 1, 1), 'yyy')
|
38
|
-
assert_equal '2345', format(Date.new( 2345, 1, 1), 'yyy')
|
39
|
-
assert_equal '12345', format(Date.new(12345, 1, 1), 'yyy')
|
40
|
-
end
|
41
|
-
|
42
|
-
define_method "test: pattern yyyy" do
|
43
|
-
assert_equal '0005', format(Date.new( 5, 1, 1), 'yyyy')
|
44
|
-
assert_equal '0045', format(Date.new( 45, 1, 1), 'yyyy')
|
45
|
-
assert_equal '0345', format(Date.new( 345, 1, 1), 'yyyy')
|
46
|
-
assert_equal '2345', format(Date.new( 2345, 1, 1), 'yyyy')
|
47
|
-
assert_equal '12345', format(Date.new(12345, 1, 1), 'yyyy')
|
48
|
-
end
|
49
|
-
|
50
|
-
define_method "test: pattern yyyyy" do
|
51
|
-
assert_equal '00005', format(Date.new( 5, 1, 1), 'yyyyy')
|
52
|
-
assert_equal '00045', format(Date.new( 45, 1, 1), 'yyyyy')
|
53
|
-
assert_equal '00345', format(Date.new( 345, 1, 1), 'yyyyy')
|
54
|
-
assert_equal '02345', format(Date.new( 2345, 1, 1), 'yyyyy')
|
55
|
-
assert_equal '12345', format(Date.new(12345, 1, 1), 'yyyyy')
|
56
|
-
end
|
57
|
-
end
|
data/test/formats/format_test.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
class TestCldrFormat < Test::Unit::TestCase
|
6
|
-
class Cldr
|
7
|
-
include ::Cldr::Format
|
8
|
-
|
9
|
-
def lookup_format(locale, type, format)
|
10
|
-
key = case type
|
11
|
-
when :date, :datetime, :time
|
12
|
-
::Cldr::Data::Calendars.new(locale)[:calendars][:gregorian][:formats][type][format][:pattern]
|
13
|
-
else
|
14
|
-
::Cldr::Data::Numbers.new(locale)[:numbers][:formats][type][:patterns][format || :default]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def lookup_format_data(locale, type)
|
19
|
-
case type
|
20
|
-
when :date, :datetime, :time
|
21
|
-
::Cldr::Data::Calendars.new(locale)[:calendars][:gregorian]
|
22
|
-
else
|
23
|
-
::Cldr::Data::Numbers.new(locale)[:numbers][:symbols]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def lookup_currency(locale, currency, count)
|
28
|
-
key = count == 1 ? :one : :other
|
29
|
-
::Cldr::Data::Currencies.new(locale)[:currencies][currency.to_sym][:key]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def setup
|
34
|
-
@cldr = Cldr.new
|
35
|
-
end
|
36
|
-
|
37
|
-
define_method :"test: format" do
|
38
|
-
assert_equal '123.456,78', @cldr.format(:de, 123456.78)
|
39
|
-
end
|
40
|
-
|
41
|
-
define_method :"test: format_currency" do
|
42
|
-
assert_equal '123.456,78 EUR', @cldr.format(:de, 123456.78, :currency => 'EUR')
|
43
|
-
end
|
44
|
-
|
45
|
-
define_method :"test: format_percent" do
|
46
|
-
assert_equal '123.457 %', @cldr.format(:de, 123456.78, :as => :percent)
|
47
|
-
end
|
48
|
-
|
49
|
-
define_method :"test: format_date" do
|
50
|
-
assert_equal 'Freitag, 1. Januar 2010', @cldr.format(:de, Date.new(2010, 1, 1), :format => :full)
|
51
|
-
end
|
52
|
-
|
53
|
-
define_method :"test: format_time :long" do
|
54
|
-
assert_equal '13:15:17 UTC', @cldr.format(:de, Time.utc(2010, 1, 1, 13, 15, 17), :format => :long)
|
55
|
-
end
|
56
|
-
|
57
|
-
define_method :"test: format_datetime :long" do
|
58
|
-
datetime = DateTime.new(2010, 11, 12, 13, 14, 15)
|
59
|
-
assert_equal '12. November 2010 13:14:15 +00:00', @cldr.format(:de, datetime, :format => :long)
|
60
|
-
end
|
61
|
-
|
62
|
-
define_method :"test: format_datetime mixed :long + :short" do
|
63
|
-
datetime = DateTime.new(2010, 11, 12, 13, 14, 15)
|
64
|
-
assert_equal '12. November 2010 13:14', @cldr.format(:de, datetime, :format => :long, :date_format => :long, :time_format => :short)
|
65
|
-
end
|
66
|
-
end
|