when_exe 0.3.2 → 0.3.3
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.
- data/LICENSE.ja.txt +25 -25
- data/LICENSE.txt +31 -31
- data/bin/locales.rb +2 -1
- data/bin/when.rb.config +1 -1
- data/lib/when_exe.rb +70 -48
- data/lib/when_exe/basictypes.rb +99 -65
- data/lib/when_exe/calendartypes.rb +40 -178
- data/lib/when_exe/coordinates.rb +156 -62
- data/lib/when_exe/core/compatibility.rb +10 -0
- data/lib/when_exe/core/extension.rb +40 -0
- data/lib/when_exe/ephemeris.rb +112 -50
- data/lib/when_exe/icalendar.rb +125 -91
- data/lib/when_exe/inspect.rb +100 -48
- data/lib/when_exe/locales/ar.rb +48 -48
- data/lib/when_exe/locales/bg.rb +1 -1
- data/lib/when_exe/locales/bs.rb +4 -2
- data/lib/when_exe/locales/ca.rb +1 -1
- data/lib/when_exe/locales/en_CA.rb +3 -4
- data/lib/when_exe/locales/en_IE.rb +88 -0
- data/lib/when_exe/locales/en_US.rb +87 -0
- data/lib/when_exe/locales/es_CR.rb +84 -0
- data/lib/when_exe/locales/es_EC.rb +85 -0
- data/lib/when_exe/locales/es_PA.rb +85 -0
- data/lib/when_exe/locales/fr.rb +39 -39
- data/lib/when_exe/locales/hu.rb +15 -14
- data/lib/when_exe/locales/it.rb +1 -1
- data/lib/when_exe/locales/ja.rb +2 -2
- data/lib/when_exe/locales/locales.rb +7 -0
- data/lib/when_exe/locales/lt.rb +21 -19
- data/lib/when_exe/locales/ms.rb +84 -0
- data/lib/when_exe/locales/nl.rb +2 -2
- data/lib/when_exe/locales/ru.rb +1 -1
- data/lib/when_exe/locales/uk.rb +1 -1
- data/lib/when_exe/locales/ur.rb +84 -0
- data/lib/when_exe/mini_application.rb +44 -43
- data/lib/when_exe/parts/enumerator.rb +3 -3
- data/lib/when_exe/parts/geometric_complex.rb +6 -1
- data/lib/when_exe/parts/locale.rb +49 -18
- data/lib/when_exe/parts/method_cash.rb +61 -0
- data/lib/when_exe/parts/resource.rb +221 -106
- data/lib/when_exe/parts/timezone.rb +70 -33
- data/lib/when_exe/region/bahai.rb +2 -2
- data/lib/when_exe/region/balinese.rb +40 -43
- data/lib/when_exe/region/chinese.rb +93 -33
- data/lib/when_exe/region/chinese_calendar.rb +117 -1
- data/lib/when_exe/region/chinese_epoch.rb +65 -10
- data/lib/when_exe/region/christian.rb +97 -2
- data/lib/when_exe/region/ephemeric_notes.rb +353 -0
- data/lib/when_exe/region/french.rb +1 -1
- data/lib/when_exe/region/geologicalage.rb +171 -171
- data/lib/when_exe/region/indian.rb +18 -14
- data/lib/when_exe/region/iranian.rb +1 -1
- data/lib/when_exe/region/japanese.rb +49 -12
- data/lib/when_exe/region/japanese_notes.rb +838 -507
- data/lib/when_exe/region/japanese_residues.rb +724 -662
- data/lib/when_exe/region/javanese.rb +7 -7
- data/lib/when_exe/region/mayan.rb +19 -17
- data/lib/when_exe/region/nihon_shoki.rb +3 -3
- data/lib/when_exe/region/residue.rb +29 -28
- data/lib/when_exe/region/shire.rb +2 -2
- data/lib/when_exe/region/tibetan.rb +87 -5
- data/lib/when_exe/region/world.rb +1 -1
- data/lib/when_exe/timestandard.rb +85 -7
- data/lib/when_exe/tmobjects.rb +32 -4
- data/lib/when_exe/tmposition.rb +104 -55
- data/lib/when_exe/tmreference.rb +157 -60
- data/lib/when_exe/version.rb +2 -2
- data/test/examples/JapanHolidays.ics +3 -3
- data/test/examples/JapanHolidaysRFC6350.ics +499 -0
- data/test/examples/Residue.m17n +3 -2
- data/test/examples/Spatial.m17n +3 -3
- data/test/examples/USA-DST.ics +27 -27
- data/test/examples/today.rb +1 -1
- data/test/test.rb +4 -2
- data/test/test/basictypes.rb +40 -15
- data/test/test/coordinates.rb +9 -4
- data/test/test/icalendar.rb +24 -14
- data/test/test/inspect.rb +5 -3
- data/test/test/parts.rb +11 -2
- data/test/test/region/chinese.rb +4 -4
- data/test/test/region/civil.rb +124 -0
- data/test/test/region/geologicalage.rb +5 -2
- data/test/test/region/indian.rb +2 -0
- data/test/test/region/japanese.rb +156 -1
- data/test/test/region/jewish.rb +3 -3
- data/test/test/region/m17n.rb +9 -9
- data/test/test/region/mayan.rb +122 -5
- data/test/test/region/residue.rb +1 -1
- data/test/test/tmobjects.rb +27 -64
- data/test/test/tmposition.rb +48 -1
- data/test/test/tmreference.rb +66 -4
- data/when_exe.gemspec +1 -1
- metadata +15 -6
data/test/test/region/chinese.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -11,7 +11,7 @@ module Test
|
|
|
11
11
|
class Chinese < Test::Unit::TestCase
|
|
12
12
|
def test_chinese_date
|
|
13
13
|
|
|
14
|
-
emd = When.Resource('_c:EphemerisBasedSolar')
|
|
14
|
+
emd = When.Resource('_c:EphemerisBasedSolar?time_basis=+09:00')
|
|
15
15
|
date = When.when?('2009-01-01', {:frame=>emd})
|
|
16
16
|
[
|
|
17
17
|
["2009-01-01", 2454867],
|
|
@@ -31,7 +31,7 @@ module Test
|
|
|
31
31
|
date += When.Duration('P1M')
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
cc = When::CalendarTypes::ChineseLuniSolar.new({'
|
|
34
|
+
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00'})
|
|
35
35
|
date = When.when?('2009-01-01', {:frame=>cc})
|
|
36
36
|
[
|
|
37
37
|
["2009-01-01", 2454858],
|
|
@@ -91,7 +91,7 @@ module Test
|
|
|
91
91
|
date += When.Duration('P1M')
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
cc = When::CalendarTypes::ChineseLuniSolar.new({'
|
|
94
|
+
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00', 'intercalary_span'=>3})
|
|
95
95
|
date = When.when?('2728-11-01', {:frame=>cc})
|
|
96
96
|
[
|
|
97
97
|
["2728-11-01", 2717768],
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 2012-2014 Takashi SUGA
|
|
4
|
+
|
|
5
|
+
You may use and/or modify this file according to the license
|
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
|
7
|
+
=end
|
|
8
|
+
|
|
9
|
+
module Test
|
|
10
|
+
|
|
11
|
+
class Civil < Test::Unit::TestCase
|
|
12
|
+
def test__border
|
|
13
|
+
frame = When.Calendar('Civil?reform=1752-9-14&border=0-3-25(1753)0-1-1')
|
|
14
|
+
assert_equal("1641=03-24", (frame ^ When.when?('1642-4-3') ).to_s)
|
|
15
|
+
assert_equal("1642-03-25", (frame ^ When.when?('1642-4-4') ).to_s)
|
|
16
|
+
assert_equal("1752-12-31", (frame ^ When.when?('1752-12-31')).to_s)
|
|
17
|
+
assert_equal("1753-01-01", (frame ^ When.when?('1753-1-1') ).to_s)
|
|
18
|
+
assert_equal("1753-03-24", (frame ^ When.when?('1753-3-24') ).to_s)
|
|
19
|
+
assert_equal("1753-03-25", (frame ^ When.when?('1753-3-25') ).to_s)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test__reform_inc
|
|
23
|
+
sample = %w(
|
|
24
|
+
1582-09-30 1582-10-01 1582-10-02 1582-10-03 1582-10-04 1582-10-15 1582-10-16 1582-10-17
|
|
25
|
+
1582-10-18 1582-10-19 1582-10-20 1582-10-21 1582-10-22 1582-10-23 1582-10-24 1582-10-25
|
|
26
|
+
1582-10-26 1582-10-27 1582-10-28 1582-10-29 1582-10-30 1582-10-31 1582-11-01 1582-11-02
|
|
27
|
+
1582-11-03)
|
|
28
|
+
date = When.when?('1582-9-30', :frame=>'Civil?reform=1582-10-15')
|
|
29
|
+
25.times do
|
|
30
|
+
assert_equal(sample.shift, date.to_s)
|
|
31
|
+
date = date + When::DurationP1D
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test__reform_dec
|
|
36
|
+
sample = %w(
|
|
37
|
+
1582-11-01 1582-10-31 1582-10-30 1582-10-29 1582-10-28 1582-10-27 1582-10-26 1582-10-25
|
|
38
|
+
1582-10-24 1582-10-23 1582-10-22 1582-10-21 1582-10-20 1582-10-19 1582-10-18 1582-10-17
|
|
39
|
+
1582-10-16 1582-10-15 1582-10-04 1582-10-03 1582-10-02 1582-10-01 1582-09-30 1582-09-29
|
|
40
|
+
1582-09-28)
|
|
41
|
+
date = When.when?('1582-11-01', :frame=>'Civil?reform=1582-10-15')
|
|
42
|
+
25.times do
|
|
43
|
+
assert_equal(sample.shift, date.to_s)
|
|
44
|
+
date = date - When::DurationP1D
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test__reform_year
|
|
49
|
+
date = When.when?('1752^^Civil?reform=1752-9-14&border=(1000)0-3-25(1753)0-1-1')
|
|
50
|
+
assert_equal(
|
|
51
|
+
[[1752,
|
|
52
|
+
[[3,
|
|
53
|
+
["*", 1, 2, 3, 4, 5, 6, 7],
|
|
54
|
+
["*", 8, 9, 10, 11, 12, 13, 14],
|
|
55
|
+
["*", 15, 16, 17, 18, 19, 20, 21],
|
|
56
|
+
["*", 22, 23, 24, 25, 26, 27, 28],
|
|
57
|
+
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
|
58
|
+
[[4,
|
|
59
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
|
60
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
|
61
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
|
62
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
|
63
|
+
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
|
64
|
+
[[5,
|
|
65
|
+
["*", "*", "*", "*", "*", "*", 1, 2],
|
|
66
|
+
["*", 3, 4, 5, 6, 7, 8, 9],
|
|
67
|
+
["*", 10, 11, 12, 13, 14, 15, 16],
|
|
68
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
|
69
|
+
["*", 24, 25, 26, 27, 28, 29, 30],
|
|
70
|
+
["*", 31, "*", "*", "*", "*", "*", "*"]]],
|
|
71
|
+
[[6,
|
|
72
|
+
["*", "*", 1, 2, 3, 4, 5, 6],
|
|
73
|
+
["*", 7, 8, 9, 10, 11, 12, 13],
|
|
74
|
+
["*", 14, 15, 16, 17, 18, 19, 20],
|
|
75
|
+
["*", 21, 22, 23, 24, 25, 26, 27],
|
|
76
|
+
["*", 28, 29, 30, "*", "*", "*", "*"]]],
|
|
77
|
+
[[7,
|
|
78
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
|
79
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
|
80
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
|
81
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
|
82
|
+
["*", 26, 27, 28, 29, 30, 31, "*"]]],
|
|
83
|
+
[[8,
|
|
84
|
+
["*", "*", "*", "*", "*", "*", "*", 1],
|
|
85
|
+
["*", 2, 3, 4, 5, 6, 7, 8],
|
|
86
|
+
["*", 9, 10, 11, 12, 13, 14, 15],
|
|
87
|
+
["*", 16, 17, 18, 19, 20, 21, 22],
|
|
88
|
+
["*", 23, 24, 25, 26, 27, 28, 29],
|
|
89
|
+
["*", 30, 31, "*", "*", "*", "*", "*"]]],
|
|
90
|
+
[[9,
|
|
91
|
+
["*", "*", "*", 1, 2, 14, 15, 16],
|
|
92
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
|
93
|
+
["*", 24, 25, 26, 27, 28, 29, 30]]],
|
|
94
|
+
[[10,
|
|
95
|
+
["*", 1, 2, 3, 4, 5, 6, 7],
|
|
96
|
+
["*", 8, 9, 10, 11, 12, 13, 14],
|
|
97
|
+
["*", 15, 16, 17, 18, 19, 20, 21],
|
|
98
|
+
["*", 22, 23, 24, 25, 26, 27, 28],
|
|
99
|
+
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
|
100
|
+
[[11,
|
|
101
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
|
102
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
|
103
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
|
104
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
|
105
|
+
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
|
106
|
+
[[12,
|
|
107
|
+
["*", "*", "*", "*", "*", "*", 1, 2],
|
|
108
|
+
["*", 3, 4, 5, 6, 7, 8, 9],
|
|
109
|
+
["*", 10, 11, 12, 13, 14, 15, 16],
|
|
110
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
|
111
|
+
["*", 24, 25, 26, 27, 28, 29, 30],
|
|
112
|
+
["*", 31, "*", "*", "*", "*", "*", "*"]]]]],
|
|
113
|
+
date.year_included('Sunday') {|d,b|
|
|
114
|
+
case b
|
|
115
|
+
when When::YEAR ; d[When::YEAR]
|
|
116
|
+
when When::MONTH ; d[When::MONTH]
|
|
117
|
+
when When::DAY ; d[When::DAY]
|
|
118
|
+
else ; '*'
|
|
119
|
+
end
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011 Takashi SUGA
|
|
3
|
+
Copyright (C) 2011-2013 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
module Test::TM
|
|
10
10
|
class GeologicalAge < Test::Unit::TestCase
|
|
11
|
-
def
|
|
11
|
+
def test__geological_age
|
|
12
|
+
age = When.Resource('_tm:OrdinalReferenceSystem/GeologicalAge')
|
|
13
|
+
assert_equal("-2500000000", age['始生代::新始生代'].end.to_s)
|
|
14
|
+
assert_equal("-09700", age['顕生代::新生代::第四紀::完新世'].begin.to_s)
|
|
12
15
|
end
|
|
13
16
|
end
|
|
14
17
|
end
|
data/test/test/region/indian.rb
CHANGED
|
@@ -50,6 +50,8 @@ module Test
|
|
|
50
50
|
cc = When.Calendar('HinduSolar?type=SBS')
|
|
51
51
|
date = When.when?('1913-01-01', {:frame=>cc})
|
|
52
52
|
assert_equal([2448361, "1913-01-01", "1991-04-14"], [date.to_i, date.to_s, date.to_date.to_s])
|
|
53
|
+
date = When::CalendarTypes::CalendarNote::HinduNote::Dates.new(date)
|
|
54
|
+
assert_equal(2448361, date.to_i)
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -42,6 +42,161 @@ module Test
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def test__solar_terms
|
|
46
|
+
sample = [
|
|
47
|
+
[ # 修正後
|
|
48
|
+
["貞観12(0870).07.17T+00", []],
|
|
49
|
+
["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損", "没"]],
|
|
50
|
+
["貞観12(0870).07.19T+00", []],
|
|
51
|
+
|
|
52
|
+
["天喜05(1057).03.10T+00", []],
|
|
53
|
+
["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
|
|
54
|
+
["天喜05(1057).03.12T+00", []],
|
|
55
|
+
|
|
56
|
+
["建仁02(1202).10=29T+00", ["没"]],
|
|
57
|
+
["建仁02(1202).11.01T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
|
|
58
|
+
["建仁02(1202).11.02T+00", []],
|
|
59
|
+
["建仁02(1202).11.03T+00", []],
|
|
60
|
+
|
|
61
|
+
["寛元01(1243).11.03T+00", []],
|
|
62
|
+
["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚", "没"]],
|
|
63
|
+
["寛元01(1243).11.05T+00", []],
|
|
64
|
+
|
|
65
|
+
["弘安04(1281).07=30T+00", ["没"]],
|
|
66
|
+
["弘安04(1281).08.01T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
|
|
67
|
+
["弘安04(1281).08.02T+00", []],
|
|
68
|
+
|
|
69
|
+
["永享02(1430).07.11T+00", ["没"]],
|
|
70
|
+
["永享02(1430).07.12T+00", []],
|
|
71
|
+
["永享02(1430).07.13T+00", []],
|
|
72
|
+
["永享02(1430).07.14T+00", ["大夫節"]],
|
|
73
|
+
["永享02(1430).07.15T+00", []],
|
|
74
|
+
["永享02(1430).07.16T+00", ["白露降"]],
|
|
75
|
+
["永享02(1430).07.17T+00", []],
|
|
76
|
+
["永享02(1430).07.18T+00", []],
|
|
77
|
+
["永享02(1430).07.19T+00", ["往亡"]],
|
|
78
|
+
["永享02(1430).07.20T+00", ["卿同人"]],
|
|
79
|
+
["永享02(1430).07.21T+00", ["寒蟬鳴"]],
|
|
80
|
+
["永享02(1430).07.22T+00", []],
|
|
81
|
+
["永享02(1430).07.23T+00", []],
|
|
82
|
+
["永享02(1430).07.24T+00", []],
|
|
83
|
+
["永享02(1430).07.25T+00", []],
|
|
84
|
+
|
|
85
|
+
["元和03(1617).03.18T+00", []],
|
|
86
|
+
["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
|
|
87
|
+
["元和03(1617).03.20T+00", []],
|
|
88
|
+
|
|
89
|
+
["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
|
|
90
|
+
["平成06(1994).06.22T+09:00", []]
|
|
91
|
+
],
|
|
92
|
+
|
|
93
|
+
[ # 修正前
|
|
94
|
+
["貞観12(0870).07.17T+00", ["没"]],
|
|
95
|
+
["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損"]],
|
|
96
|
+
["貞観12(0870).07.19T+00", []],
|
|
97
|
+
|
|
98
|
+
["天喜05(1057).03.10T+00", ["没"]],
|
|
99
|
+
["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革"]],
|
|
100
|
+
["天喜05(1057).03.12T+00", []],
|
|
101
|
+
|
|
102
|
+
["建仁02(1202).10=29T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
|
|
103
|
+
["建仁02(1202).11.01T+00", []],
|
|
104
|
+
["建仁02(1202).11.02T+00", []],
|
|
105
|
+
["建仁02(1202).11.03T+00", ["没"]],
|
|
106
|
+
|
|
107
|
+
["寛元01(1243).11.03T+00", ["没"]],
|
|
108
|
+
["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
|
|
109
|
+
["寛元01(1243).11.05T+00", []],
|
|
110
|
+
|
|
111
|
+
["弘安04(1281).07=30T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
|
|
112
|
+
["弘安04(1281).08.01T+00", []],
|
|
113
|
+
["弘安04(1281).08.02T+00", ["没"]],
|
|
114
|
+
|
|
115
|
+
["永享02(1430).07.11T+00", []],
|
|
116
|
+
["永享02(1430).07.12T+00", []],
|
|
117
|
+
["永享02(1430).07.13T+00", ["大夫節"]],
|
|
118
|
+
["永享02(1430).07.14T+00", []],
|
|
119
|
+
["永享02(1430).07.15T+00", ["白露降"]],
|
|
120
|
+
["永享02(1430).07.16T+00", []],
|
|
121
|
+
["永享02(1430).07.17T+00", []],
|
|
122
|
+
["永享02(1430).07.18T+00", ["往亡"]],
|
|
123
|
+
["永享02(1430).07.19T+00", ["卿同人"]],
|
|
124
|
+
["永享02(1430).07.20T+00", ["寒蟬鳴"]],
|
|
125
|
+
["永享02(1430).07.21T+00", []],
|
|
126
|
+
["永享02(1430).07.22T+00", []],
|
|
127
|
+
["永享02(1430).07.23T+00", []],
|
|
128
|
+
["永享02(1430).07.24T+00", []],
|
|
129
|
+
["永享02(1430).07.25T+00", ["没"]],
|
|
130
|
+
|
|
131
|
+
["元和03(1617).03.18T+00", ["没"]],
|
|
132
|
+
["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革"]],
|
|
133
|
+
["元和03(1617).03.20T+00", []],
|
|
134
|
+
|
|
135
|
+
["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
|
|
136
|
+
["平成06(1994).06.22T+09:00", []]
|
|
137
|
+
]
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
2.times do
|
|
141
|
+
result = []
|
|
142
|
+
[2039054..2039056,
|
|
143
|
+
2107233..2107235,
|
|
144
|
+
2160437..2160440,
|
|
145
|
+
2175412..2175414,
|
|
146
|
+
2189200..2189202,
|
|
147
|
+
2243577..2243591,
|
|
148
|
+
2311770..2311772,
|
|
149
|
+
2449525..2449526].each do |range|
|
|
150
|
+
range.each do |jdn|
|
|
151
|
+
(When.when?(jdn) ^ When.CalendarEra('Japanese')).each do |date|
|
|
152
|
+
dates = When.CalendarNote('JapaneseNote').send(:_to_date_for_note, date)
|
|
153
|
+
date = When.when?(dates.o_date.to_cal_date.to_s,
|
|
154
|
+
{:clock=>dates.s_date.frame.time_basis})
|
|
155
|
+
long = dates.cal4note.s_terms.position(date)
|
|
156
|
+
notes = date.notes(:indices => When::DAY,
|
|
157
|
+
:notes => (13<<9|1<<48|1<<71),
|
|
158
|
+
:locale => 'ja').map {|n| n[:value]}
|
|
159
|
+
result << [date.to_m17n/'ja', notes]
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
assert_equal(sample.shift, result)
|
|
164
|
+
When::CalendarTypes::CalendarNote::JapaneseNote::SolarTerms.send(:patch=, {})
|
|
165
|
+
end
|
|
166
|
+
When::CalendarTypes::CalendarNote::JapaneseNote::SolarTerms.send(:patch=, nil)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def test__lunar_phases
|
|
170
|
+
[%w(康和3.01.09 康和3.01.16 康和3.01.23),
|
|
171
|
+
%w(康和3.02.08 康和3.02.16 康和3.02.23),
|
|
172
|
+
%w(康和3.03.08 康和3.03.15 康和3.03.22),
|
|
173
|
+
%w(康和3.04.09 康和3.04.16 康和3.04.23),
|
|
174
|
+
%w(康和3.05.08 康和3.05.15 康和3.05.22),
|
|
175
|
+
%w(康和3.06.08 康和3.06.15 康和3.06.23),
|
|
176
|
+
%w(康和3.07.08 康和3.07.15 康和3.07.22),
|
|
177
|
+
%w(康和3.08.07 康和3.08.14 康和3.08.22),
|
|
178
|
+
%w(康和3.09.07 康和3.09.15 康和3.09.23),
|
|
179
|
+
%w(康和3.10.08 康和3.10.15 康和3.10.23),
|
|
180
|
+
%w(康和3.11.07 康和3.11.15 康和3.11.23),
|
|
181
|
+
%w(康和3.12.08 康和3.12.16 康和3.12.23),
|
|
182
|
+
|
|
183
|
+
%w(平成26.01.01 平成26.01.08 平成26.01.16 平成26.01.24),
|
|
184
|
+
%w(平成26.01.31 平成26.02.07 平成26.02.15 平成26.02.23),
|
|
185
|
+
%w(平成26.03.01 平成26.03.08 平成26.03.17 平成26.03.24),
|
|
186
|
+
%w(平成26.03.31 平成26.04.07 平成26.04.15 平成26.04.22),
|
|
187
|
+
%w(平成26.04.29 平成26.05.07 平成26.05.15 平成26.05.21),
|
|
188
|
+
%w(平成26.05.29 平成26.06.06 平成26.06.13 平成26.06.20),
|
|
189
|
+
%w(平成26.06.27 平成26.07.05 平成26.07.12 平成26.07.19),
|
|
190
|
+
%w(平成26.07.27 平成26.08.04 平成26.08.11 平成26.08.17),
|
|
191
|
+
%w(平成26.08.25 平成26.09.02 平成26.09.09 平成26.09.16),
|
|
192
|
+
%w(平成26.09.24 平成26.10.02 平成26.10.08 平成26.10.16),
|
|
193
|
+
%w(平成26.10.24 平成26.10.31 平成26.11.07 平成26.11.15),
|
|
194
|
+
%w(平成26.11.22 平成26.11.29 平成26.12.06 平成26.12.14),
|
|
195
|
+
%w(平成26.12.22 平成26.12.29)
|
|
196
|
+
].each do |month|
|
|
197
|
+
assert_equal([true], month.map {|date| When.when?(date).notes('月相').kind_of?(Hash)}.uniq)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
45
200
|
=begin
|
|
46
201
|
def test_japanese_date
|
|
47
202
|
jc = When.Resource('_c:Japanese')
|
data/test/test/region/jewish.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -53,8 +53,8 @@ module Test
|
|
|
53
53
|
date += When.Duration('P1Y')
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
assert_equal("BCE3761(-3760).10.07",
|
|
57
|
-
(When.era('BCE')[0] ^ When.Calendar('Jewish').domain.first).to_s)
|
|
56
|
+
assert_equal("Common::BCE3761(-3760).10.07",
|
|
57
|
+
(When.era('BCE')[0] ^ When.Calendar('Jewish').domain[''].first).to_s)
|
|
58
58
|
|
|
59
59
|
end
|
|
60
60
|
end
|
data/test/test/region/m17n.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -121,10 +121,10 @@ module Test
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
def
|
|
124
|
+
def test__to_h
|
|
125
125
|
[
|
|
126
126
|
['HLC0.0.0.0.0',
|
|
127
|
-
{:calendar=>["_e:
|
|
127
|
+
{:calendar=>["_e:LongCount::PHLC",-13], :sdn=>584283, :cal_date=>[13, 0, 0, 0, 0],
|
|
128
128
|
:notes=>[[{:note=>"Trecena", :value=>"Trecena(4/13)"},
|
|
129
129
|
{:note=>"Tzolk'in", :value=>"Ajaw(19/20)"},
|
|
130
130
|
{:note=>"Lords_of_the_Night", :value=>"G9(0/9)"},
|
|
@@ -137,9 +137,9 @@ module Test
|
|
|
137
137
|
['明治7.5.7',
|
|
138
138
|
{:calendar=>["_e:Japanese::明治",1867], :sdn=>2405651, :cal_date=>[7, 5, 7],
|
|
139
139
|
:notes=>[[{:note=>"干支", :value=>"甲戌(10)", :position=>"共通"}],
|
|
140
|
-
[{:note=>"月名", :value=>"May",
|
|
141
|
-
[{:note=>"干支", :value=>"甲子(
|
|
142
|
-
{:note=>"六曜", :value=>"赤口",
|
|
140
|
+
[{:note=>"月名", :value=>"May", :position=>"月建"}],
|
|
141
|
+
[{:note=>"干支", :value=>"甲子(00)", :position=>"共通"},
|
|
142
|
+
{:note=>"六曜", :value=>"赤口", :position=>"民間"}]]}],
|
|
143
143
|
|
|
144
144
|
['明治17.5.7',
|
|
145
145
|
{:calendar=>["_e:Japanese::明治",1867], :sdn=>2409304, :cal_date=>[17, 5, 7],
|
|
@@ -156,17 +156,17 @@ module Test
|
|
|
156
156
|
[11,
|
|
157
157
|
{:calendar=>["_tm:JulianDate"], :sdn=>11,
|
|
158
158
|
:notes=>[[{:note=>"Week", :value=>"Friday(4)"},
|
|
159
|
-
{:note=>"干支", :value=>"甲子(
|
|
159
|
+
{:note=>"干支", :value=>"甲子(00)"}]]}],
|
|
160
160
|
|
|
161
161
|
[11.0,
|
|
162
162
|
{:calendar=>["_tm:JulianDate"], :sdn=>11,
|
|
163
163
|
:notes=>[[{:note=>"Week", :value=>"Friday(4)"},
|
|
164
|
-
{:note=>"干支", :value=>"甲子(
|
|
164
|
+
{:note=>"干支", :value=>"甲子(00)"}]],
|
|
165
165
|
:clk_time=>[11, 12, 0, 0]}]
|
|
166
166
|
|
|
167
167
|
].each do |sample|
|
|
168
168
|
date, verify = sample
|
|
169
|
-
list = When.when?(date).
|
|
169
|
+
list = When.when?(date).to_h({:simple=>true})
|
|
170
170
|
[:calendar, :cal_date, :sdn, :clk_time].each do |key|
|
|
171
171
|
assert_equal(verify[key], list[key])
|
|
172
172
|
end
|
data/test/test/region/mayan.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license
|
|
6
6
|
described in the LICENSE.txt file included in this archive.
|
|
@@ -10,10 +10,29 @@ module Test
|
|
|
10
10
|
|
|
11
11
|
class Mayan < Test::Unit::TestCase
|
|
12
12
|
def test__mayan_epoch
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
['
|
|
16
|
-
['HLC13.0.0.0.
|
|
13
|
+
# No offset
|
|
14
|
+
[['PHLC13.0.0.0.0', 'PHLC13(0000).00.00.00.00', 584283],
|
|
15
|
+
['HLC0.0.0.0.1', 'HLC00.00.00.00.01', 584284],
|
|
16
|
+
['HLC13.0.0.0.0', 'HLC13.00.00.00.00', 2456283],
|
|
17
|
+
['HLC13.0.0.0.1', 'NLC00(0013).00.00.00.01', 2456284]].each do |sample|
|
|
18
|
+
date = When.when?(sample.shift)
|
|
19
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# offset 0B
|
|
23
|
+
[['LongCount?Epoch=0D::PHLC13.0.0.0.0', 'LongCount?Epoch=0D::PHLC13(0000).00.00.00.00', 584283],
|
|
24
|
+
['LongCount?Epoch=0D::HLC0.0.0.0.1', 'LongCount?Epoch=0D::HLC00.00.00.00.01', 584284],
|
|
25
|
+
['LongCount?Epoch=0D::HLC13.0.0.0.0', 'LongCount?Epoch=0D::HLC13.00.00.00.00', 2456283],
|
|
26
|
+
['LongCount?Epoch=0D::HLC13.0.0.0.1', 'LongCount?Epoch=0D::NLC00(0013).00.00.00.01', 2456284]].each do |sample|
|
|
27
|
+
date = When.when?(sample.shift)
|
|
28
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# offset 2B
|
|
32
|
+
[['LongCount?Epoch=2D::PHLC13.0.0.0.0', 'LongCount?Epoch=2D::PHLC13(0000).00.00.00.00', 584285],
|
|
33
|
+
['LongCount?Epoch=2D::HLC0.0.0.0.1', 'LongCount?Epoch=2D::HLC00.00.00.00.01', 584286],
|
|
34
|
+
['LongCount?Epoch=2D::HLC13.0.0.0.0', 'LongCount?Epoch=2D::HLC13.00.00.00.00', 2456285],
|
|
35
|
+
['LongCount?Epoch=2D::HLC13.0.0.0.1', 'LongCount?Epoch=2D::NLC00(0013).00.00.00.01', 2456286]].each do |sample|
|
|
17
36
|
date = When.when?(sample.shift)
|
|
18
37
|
assert_equal(sample, [date.to_s, date.to_i])
|
|
19
38
|
end
|
|
@@ -26,6 +45,7 @@ module Test
|
|
|
26
45
|
end
|
|
27
46
|
|
|
28
47
|
def test__haab
|
|
48
|
+
# No offset
|
|
29
49
|
haab = When.Resource("_co:Mayan::Haab'")
|
|
30
50
|
assert_equal("ハアブ", haab.label.translate('ja'))
|
|
31
51
|
assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
|
|
@@ -44,9 +64,50 @@ module Test
|
|
|
44
64
|
assert_equal(42, When.when?('2011-05-15') % haab)
|
|
45
65
|
h = haab % When.when?('2011-05-15')
|
|
46
66
|
assert_equal(["Sip", 2], [h.label.to_s, h.difference])
|
|
67
|
+
|
|
68
|
+
# offset 0B
|
|
69
|
+
haab = When.Resource("_co:Mayan?Epoch=0D::Haab'")
|
|
70
|
+
assert_equal("ハアブ", haab.label.translate('ja'))
|
|
71
|
+
assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
|
|
72
|
+
pop = When.Resource("_co:Mayan?Epoch=0D::Haab'::Pop")
|
|
73
|
+
assert_equal("Pop", pop.label.translate('en'))
|
|
74
|
+
assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
|
|
75
|
+
date0 = When.when?('2011-05-16T12:34:56Z')
|
|
76
|
+
sample = [
|
|
77
|
+
"2012-04-12T12:34:56Z",
|
|
78
|
+
"2012-04-13T12:34:56Z",
|
|
79
|
+
"2012-04-14T12:34:56Z"
|
|
80
|
+
]
|
|
81
|
+
[10,11,12].each do |i|
|
|
82
|
+
assert_equal(sample.shift, (date0 & pop[i]).to_s)
|
|
83
|
+
end
|
|
84
|
+
assert_equal(42, When.when?('2011-05-15') % haab)
|
|
85
|
+
h = haab % When.when?('2011-05-15')
|
|
86
|
+
assert_equal(["Sip", 2], [h.label.to_s, h.difference])
|
|
87
|
+
|
|
88
|
+
# offset 2B
|
|
89
|
+
haab = When.Resource("_co:Mayan?Epoch=2D::Haab'")
|
|
90
|
+
assert_equal("ハアブ", haab.label.translate('ja'))
|
|
91
|
+
assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
|
|
92
|
+
pop = When.Resource("_co:Mayan?Epoch=2D::Haab'::Pop")
|
|
93
|
+
assert_equal("Pop", pop.label.translate('en'))
|
|
94
|
+
assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
|
|
95
|
+
date0 = When.when?('2011-05-16T12:34:56Z')
|
|
96
|
+
sample = [
|
|
97
|
+
"2012-04-14T12:34:56Z",
|
|
98
|
+
"2012-04-15T12:34:56Z",
|
|
99
|
+
"2012-04-16T12:34:56Z"
|
|
100
|
+
]
|
|
101
|
+
[10,11,12].each do |i|
|
|
102
|
+
assert_equal(sample.shift, (date0 & pop[i]).to_s)
|
|
103
|
+
end
|
|
104
|
+
assert_equal(42, When.when?('2011-05-17') % haab)
|
|
105
|
+
h = haab % When.when?('2011-05-17')
|
|
106
|
+
assert_equal(["Sip", 2], [h.label.to_s, h.difference])
|
|
47
107
|
end
|
|
48
108
|
|
|
49
109
|
def test__tzolkin
|
|
110
|
+
# No offset
|
|
50
111
|
trecena = When.Resource("_co:Mayan::Trecena")
|
|
51
112
|
assert_equal("トレセナ", trecena.label.translate('ja'))
|
|
52
113
|
assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
|
|
@@ -73,6 +134,62 @@ module Test
|
|
|
73
134
|
if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
|
|
74
135
|
assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
|
|
75
136
|
end
|
|
137
|
+
|
|
138
|
+
# offset 0B
|
|
139
|
+
trecena = When.Resource("_co:Mayan?Epoch=0D::Trecena")
|
|
140
|
+
assert_equal("トレセナ", trecena.label.translate('ja'))
|
|
141
|
+
assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
|
|
142
|
+
assert_equal(2, When.when?('2011-05-15') % trecena)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
tzolkin = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in")
|
|
146
|
+
assert_equal("ツォルキン", tzolkin.label.translate('ja'))
|
|
147
|
+
assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
|
|
148
|
+
ajaw = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in::Ajaw")
|
|
149
|
+
assert_equal("Ajaw", ajaw.label.translate('en'))
|
|
150
|
+
assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
|
|
151
|
+
date0 = When.when?('2011-05-16T12:34:56Z')
|
|
152
|
+
sample = [
|
|
153
|
+
"2011-05-21T12:34:56Z",
|
|
154
|
+
"2011-05-21T12:34:56Z",
|
|
155
|
+
"2011-05-21T12:34:56Z"
|
|
156
|
+
]
|
|
157
|
+
[10,11,12].each do |i|
|
|
158
|
+
assert_equal(sample.shift, (date0 & ajaw).to_s)
|
|
159
|
+
end
|
|
160
|
+
assert_equal(13, When.when?('2011-05-15') % tzolkin)
|
|
161
|
+
assert_equal('Ix', (tzolkin % When.when?('2011-05-15')).label.to_s)
|
|
162
|
+
if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
|
|
163
|
+
assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# offset 2B
|
|
167
|
+
trecena = When.Resource("_co:Mayan?Epoch=2D::Trecena")
|
|
168
|
+
assert_equal("トレセナ", trecena.label.translate('ja'))
|
|
169
|
+
assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
|
|
170
|
+
assert_equal(2, When.when?('2011-05-17') % trecena)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
tzolkin = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in")
|
|
174
|
+
assert_equal("ツォルキン", tzolkin.label.translate('ja'))
|
|
175
|
+
assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
|
|
176
|
+
ajaw = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in::Ajaw")
|
|
177
|
+
assert_equal("Ajaw", ajaw.label.translate('en'))
|
|
178
|
+
assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
|
|
179
|
+
date0 = When.when?('2011-05-16T12:34:56Z')
|
|
180
|
+
sample = [
|
|
181
|
+
"2011-05-23T12:34:56Z",
|
|
182
|
+
"2011-05-23T12:34:56Z",
|
|
183
|
+
"2011-05-23T12:34:56Z"
|
|
184
|
+
]
|
|
185
|
+
[10,11,12].each do |i|
|
|
186
|
+
assert_equal(sample.shift, (date0 & ajaw).to_s)
|
|
187
|
+
end
|
|
188
|
+
assert_equal(13, When.when?('2011-05-17') % tzolkin)
|
|
189
|
+
assert_equal('Ix', (tzolkin % When.when?('2011-05-17')).label.to_s)
|
|
190
|
+
if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
|
|
191
|
+
assert_equal('Ix', (tzolkin % Date.new(2011,5,17)).label.to_s)
|
|
192
|
+
end
|
|
76
193
|
end
|
|
77
194
|
end
|
|
78
195
|
end
|