when_exe 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +171 -0
- data/lib/when_exe.rb +78 -47
- data/lib/when_exe/basictypes.rb +752 -747
- data/lib/when_exe/calendarnote.rb +805 -801
- data/lib/when_exe/calendartypes.rb +1583 -1531
- data/lib/when_exe/coordinates.rb +16 -15
- data/lib/when_exe/core/duration.rb +114 -110
- data/lib/when_exe/core/extension.rb +504 -504
- data/lib/when_exe/ephemeris.rb +1917 -1913
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/ephemeris/notes.rb +389 -387
- data/lib/when_exe/ephemeris/planets.rb +585 -585
- data/lib/when_exe/ephemeris/sun.rb +214 -214
- data/lib/when_exe/googlecalendar.rb +144 -140
- data/lib/when_exe/icalendar.rb +1636 -1636
- data/lib/when_exe/inspect.rb +46 -22
- data/lib/when_exe/locales/akt.rb +176 -176
- data/lib/when_exe/locales/encoding_conversion.rb +134 -126
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/locale.rb +750 -746
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/mini_application.rb +307 -305
- data/lib/when_exe/parts/enumerator.rb +2 -2
- data/lib/when_exe/parts/geometric_complex.rb +397 -397
- data/lib/when_exe/parts/method_cash.rb +224 -224
- data/lib/when_exe/parts/resource.rb +1069 -1071
- data/lib/when_exe/parts/timezone.rb +240 -230
- data/lib/when_exe/region/armenian.rb +56 -56
- data/lib/when_exe/region/babylonian.rb +405 -0
- data/lib/when_exe/region/bahai.rb +146 -146
- data/lib/when_exe/region/balinese.rb +622 -622
- data/lib/when_exe/region/chinese.rb +95 -25
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/chinese/epochs.rb +1 -1
- data/lib/when_exe/region/chinese/twins.rb +803 -795
- data/lib/when_exe/region/christian.rb +824 -824
- data/lib/when_exe/region/coptic.rb +106 -87
- data/lib/when_exe/region/discordian.rb +225 -225
- data/lib/when_exe/region/far_east.rb +188 -188
- data/lib/when_exe/region/french.rb +56 -56
- data/lib/when_exe/region/geologicalage.rb +639 -639
- data/lib/when_exe/region/goddess.rb +58 -58
- data/lib/when_exe/region/indian.rb +1254 -1251
- data/lib/when_exe/region/iranian.rb +8 -8
- data/lib/when_exe/region/islamic.rb +3 -3
- data/lib/when_exe/region/japanese.rb +93 -99
- data/lib/when_exe/region/japanese/calendars.rb +396 -397
- data/lib/when_exe/region/japanese/epochs.rb +26 -26
- data/lib/when_exe/region/japanese/nihon_shoki.rb +71 -71
- data/lib/when_exe/region/japanese/notes.rb +1383 -1386
- data/lib/when_exe/region/japanese/residues.rb +1306 -1306
- data/lib/when_exe/region/japanese/twins.rb +225 -225
- data/lib/when_exe/region/japanese/weeks.rb +112 -0
- data/lib/when_exe/region/javanese.rb +230 -230
- data/lib/when_exe/region/jewish.rb +126 -126
- data/lib/when_exe/region/korean.rb +378 -378
- data/lib/when_exe/region/m17n.rb +114 -113
- data/lib/when_exe/region/martian.rb +258 -255
- data/lib/when_exe/region/mayan.rb +32 -32
- data/lib/when_exe/region/residue.rb +89 -89
- data/lib/when_exe/region/roman.rb +36 -24
- data/lib/when_exe/region/ryukyu.rb +97 -97
- data/lib/when_exe/region/shire.rb +240 -240
- data/lib/when_exe/region/soviet.rb +209 -0
- data/lib/when_exe/region/symmetry.rb +50 -50
- data/lib/when_exe/region/thai.rb +336 -335
- data/lib/when_exe/region/tibetan.rb +316 -315
- data/lib/when_exe/region/vietnamese.rb +440 -439
- data/lib/when_exe/region/weekdate.rb +80 -80
- data/lib/when_exe/region/world.rb +175 -175
- data/lib/when_exe/region/yerm.rb +14 -14
- data/lib/when_exe/region/zoroastrian.rb +203 -203
- data/lib/when_exe/timestandard.rb +707 -681
- data/lib/when_exe/tmduration.rb +338 -330
- data/lib/when_exe/tmobjects.rb +1346 -1325
- data/lib/when_exe/tmposition.rb +2115 -2072
- data/lib/when_exe/tmreference.rb +1693 -1669
- data/lib/when_exe/version.rb +1 -1
- data/link_to_online_documents +1 -1
- data/test/examples/JapanHolidaysRFC6350.ics +1 -1
- data/test/test.rb +67 -61
- data/test/test/basictypes.rb +409 -409
- data/test/test/calendarnote.rb +86 -69
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +396 -396
- data/test/test/ephemeris.rb +83 -74
- data/test/test/ephemeris/moon.rb +14 -14
- data/test/test/ephemeris/planets.rb +14 -14
- data/test/test/ephemeris/sun.rb +14 -14
- data/test/test/googlecalendar.rb +194 -176
- data/test/test/icalendar.rb +867 -858
- data/test/test/inspect.rb +117 -117
- data/test/test/parts.rb +487 -487
- data/test/test/region/balinese.rb +34 -0
- data/test/test/region/chinese.rb +218 -206
- data/test/test/region/christian.rb +245 -245
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/indian.rb +57 -57
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +18 -18
- data/test/test/region/japanese.rb +237 -219
- data/test/test/region/jewish.rb +61 -61
- data/test/test/region/m17n.rb +184 -184
- data/test/test/region/mayan.rb +195 -195
- data/test/test/region/residue.rb +147 -139
- data/test/test/region/thai.rb +116 -116
- data/test/test/region/tibetan.rb +30 -30
- data/test/test/region/vietnamese.rb +102 -102
- data/test/test/region/yerm.rb +146 -146
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +328 -328
- data/test/test/tmposition.rb +397 -284
- data/test/test/tmreference.rb +157 -157
- metadata +13 -10
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011 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 MiniTest
|
10
|
+
|
11
|
+
class Balenese< MiniTest::TestCase
|
12
|
+
def test_balinese_note
|
13
|
+
note = When::CalendarNote('Balinese')
|
14
|
+
b_date = When::Calendar('BalineseLuniSolar2003') ^ When.when?('2012-6-19')
|
15
|
+
g_date = When::Calendar('Gregorian')^b_date
|
16
|
+
assert_equal(["Ulat/Lidi" ], [note.hari(b_date).to_s, note.hari(g_date).to_s ].uniq) # hari
|
17
|
+
assert_equal(["Pepet" ], [note.dwiwara(b_date).to_s, note.dwiwara(g_date).to_s ].uniq) # dwiwara
|
18
|
+
assert_equal(["Kajeng(2)" ], [note.triwara(b_date).to_s, note.triwara(g_date).to_s ].uniq) # triwara
|
19
|
+
assert_equal(["Jaya" ], [note.tjaturwara(b_date).to_s, note.tjaturwara(g_date).to_s].uniq) # tjaturwara
|
20
|
+
assert_equal(["Wage(2)" ], [note.pantjawara(b_date).to_s, note.pantjawara(g_date).to_s].uniq) # pantjawara
|
21
|
+
assert_equal(["Urukung(2)" ], [note.perinkelan(b_date).to_s, note.perinkelan(g_date).to_s].uniq) # perinkelan
|
22
|
+
assert_equal(["Sato(2)" ], [note.sadwara(b_date).to_s, note.sadwara(g_date).to_s ].uniq) # sadwara
|
23
|
+
assert_equal(["Anggara(2)" ], [note.septawara(b_date).to_s, note.septawara(g_date).to_s ].uniq) # septawara
|
24
|
+
assert_equal(["Guru" ], [note.astawara(b_date).to_s, note.astawara(g_date).to_s ].uniq) # astawara
|
25
|
+
assert_equal(["Dangu" ], [note.sangawara(b_date).to_s, note.sangawara(g_date).to_s ].uniq) # sangawara
|
26
|
+
assert_equal(["Raja" ], [note.dasawara(b_date).to_s, note.dasawara(g_date).to_s ].uniq) # dasawara
|
27
|
+
assert_equal(["Wong(2)" ], [note.ingkel(b_date).to_s, note.ingkel(g_date).to_s ].uniq) # ingkel
|
28
|
+
assert_equal(["Watu-Lembu" ], [note.watek(b_date).to_s, note.watek(g_date).to_s ].uniq) # watek
|
29
|
+
assert_equal(["Jong Sarat(2)"], [note.lintang(b_date).to_s, note.lintang(g_date).to_s ].uniq) # lintang
|
30
|
+
assert_equal(["Sinta(2)" ], [note.wuku(b_date).to_s, note.wuku(g_date).to_s ].uniq) # wuku
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/test/test/region/chinese.rb
CHANGED
@@ -1,206 +1,218 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011-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
|
10
|
-
|
11
|
-
class Chinese <
|
12
|
-
def test_chinese_date
|
13
|
-
|
14
|
-
emd = When.Resource('_c:EphemerisBasedSolar?time_basis=+09:00')
|
15
|
-
date = When.when?('2009-01-01', {:frame=>emd})
|
16
|
-
[
|
17
|
-
["2009-01-01", 2454867],
|
18
|
-
["2009-02-01", 2454896],
|
19
|
-
["2009-03-01", 2454927],
|
20
|
-
["2009-04-01", 2454957],
|
21
|
-
["2009-05-01", 2454988],
|
22
|
-
["2009-06-01", 2455020],
|
23
|
-
["2009-07-01", 2455051],
|
24
|
-
["2009-08-01", 2455082],
|
25
|
-
["2009-09-01", 2455113],
|
26
|
-
["2009-10-01", 2455143],
|
27
|
-
["2009-11-01", 2455173],
|
28
|
-
["2009-12-01", 2455202]
|
29
|
-
].each do |sample|
|
30
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
31
|
-
date += When.Duration('P1M')
|
32
|
-
end
|
33
|
-
|
34
|
-
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00'})
|
35
|
-
date = When.when?('2009-01-01', {:frame=>cc})
|
36
|
-
[
|
37
|
-
["2009-01-01", 2454858],
|
38
|
-
["2009-02-01", 2454888],
|
39
|
-
["2009-03-01", 2454918],
|
40
|
-
["2009-04-01", 2454947],
|
41
|
-
["2009-05-01", 2454976],
|
42
|
-
["2009-05=01", 2455006],
|
43
|
-
["2009-06-01", 2455035],
|
44
|
-
["2009-07-01", 2455064],
|
45
|
-
["2009-08-01", 2455094],
|
46
|
-
["2009-09-01", 2455123],
|
47
|
-
["2009-10-01", 2455153],
|
48
|
-
["2009-11-01", 2455182],
|
49
|
-
["2009-12-01", 2455212]
|
50
|
-
].each do |sample|
|
51
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
52
|
-
date += When.Duration('P1M')
|
53
|
-
end
|
54
|
-
|
55
|
-
date = When.when?('2032-11-01', {:frame=>cc})
|
56
|
-
[
|
57
|
-
["2032-11-01", 2463570],
|
58
|
-
["2032-12-01", 2463599],
|
59
|
-
["2033-01-01", 2463629],
|
60
|
-
["2033-02-01", 2463658],
|
61
|
-
["2033-03-01", 2463688],
|
62
|
-
["2033-04-01", 2463717],
|
63
|
-
["2033-05-01", 2463746],
|
64
|
-
["2033-06-01", 2463776],
|
65
|
-
["2033-07-01", 2463805],
|
66
|
-
["2033-08-01", 2463835],
|
67
|
-
["2033-09-01", 2463864],
|
68
|
-
["2033-10-01", 2463894],
|
69
|
-
["2033-11-01", 2463924],
|
70
|
-
["2033-11=01", 2463954],
|
71
|
-
["2033-12-01", 2463983],
|
72
|
-
["2034-01-01", 2464013],
|
73
|
-
["2034-02-01", 2464042],
|
74
|
-
["2034-03-01", 2464072]
|
75
|
-
].each do |sample|
|
76
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
77
|
-
date += When.Duration('P1M')
|
78
|
-
end
|
79
|
-
|
80
|
-
date = When.when?('2728-11-01', {:frame=>cc})
|
81
|
-
[
|
82
|
-
["2728-11-01", 2717768],
|
83
|
-
["2728-11=01", 2717798],
|
84
|
-
["2728-12-01", 2717827],
|
85
|
-
["2729-01-01", 2717857],
|
86
|
-
["2729-02-01", 2717887],
|
87
|
-
["2729-03-01", 2717916],
|
88
|
-
["2729-04-01", 2717946]
|
89
|
-
].each do |sample|
|
90
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
91
|
-
date += When.Duration('P1M')
|
92
|
-
end
|
93
|
-
|
94
|
-
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00', 'intercalary_span'=>3})
|
95
|
-
date = When.when?('2728-11-01', {:frame=>cc})
|
96
|
-
[
|
97
|
-
["2728-11-01", 2717768],
|
98
|
-
["2728-12-01", 2717798],
|
99
|
-
["2729-01-01", 2717827],
|
100
|
-
["2729-02-01", 2717857],
|
101
|
-
["2729-02=01", 2717887],
|
102
|
-
["2729-03-01", 2717916],
|
103
|
-
["2729-04-01", 2717946]
|
104
|
-
].each do |sample|
|
105
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
106
|
-
date += When.Duration('P1M')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_chinese_epoch
|
111
|
-
date = When.when?('天保2.10.01')
|
112
|
-
assert_equal([2390126, "天保02(1831).10.01", "神無月"],
|
113
|
-
[date.to_i, date.to_s, date.name('Month')])
|
114
|
-
assert_equal("1831-11-04", (When.Calendar('Gregorian') ^ When.when?('天保02.10.01')).to_s)
|
115
|
-
|
116
|
-
#=begin
|
117
|
-
date = When.when?('天保2.10.01', {:count=>2})
|
118
|
-
assert_equal([1926999, "天保02(0563).10.01", "十月"],
|
119
|
-
[date.to_i, date.to_s, date.name('Month')])
|
120
|
-
|
121
|
-
date = When.when?('天保3(564).10.01')
|
122
|
-
assert_equal([1927353, "天保03(0564).10.01", "十月"],
|
123
|
-
[date.to_i, date.to_s, date.name('Month')])
|
124
|
-
|
125
|
-
date = When.when?('天保3.10.01', {'period'=>/梁/})
|
126
|
-
assert_equal([1927353, "天保03(0564).10.01", "十月"],
|
127
|
-
[date.to_i, date.to_s, date.name('Month')])
|
128
|
-
|
129
|
-
assert_equal(["江戸時代", "後梁", "北斉"],
|
130
|
-
When::era('天保').map {|v| v.parent.label}) # v.iri
|
131
|
-
|
132
|
-
assert_raises(ArgumentError) { When.when?('天保3(0563).10.01') }
|
133
|
-
|
134
|
-
date = When.when?('始皇帝26*10.01')
|
135
|
-
assert_equal([1640641, "始皇帝26(-220)*10.01", "十月"],
|
136
|
-
[date.to_i, date.to_s, date.name('Month')])
|
137
|
-
|
138
|
-
cc_221 = When.Resource('_c:Chinese_221')
|
139
|
-
[
|
140
|
-
["-220*10-01", 1640641, "-00220*10-01", "十月"],
|
141
|
-
["-220*11-01", 1640671, "-00220*11-01", "十一月"],
|
142
|
-
["-220*12-01", 1640700, "-00220*12-01", "十二月"],
|
143
|
-
["-220-01-01", 1640730, "-00220-01-01", "正月"],
|
144
|
-
["-220-02-01", 1640759, "-00220-02-01", "二月"],
|
145
|
-
["-220-03-01", 1640789, "-00220-03-01", "三月"],
|
146
|
-
["-220-04-01", 1640818, "-00220-04-01", "四月"],
|
147
|
-
["-220-05-01", 1640848, "-00220-05-01", "五月"],
|
148
|
-
["-220-06-01", 1640877, "-00220-06-01", "六月"],
|
149
|
-
["-220-07-01", 1640907, "-00220-07-01", "七月"],
|
150
|
-
["-220-08-01", 1640937, "-00220-08-01", "八月"],
|
151
|
-
["-220-09-01", 1640966, "-00220-09-01", "九月"],
|
152
|
-
["-220-09=01", 1640996, "-00220-09=01", "閏九月"]
|
153
|
-
].each do |sample|
|
154
|
-
date = When.when?(sample[0], {:frame=>cc_221})
|
155
|
-
assert_equal(sample[1..-1],
|
156
|
-
[date.to_i, date.to_s, date.name('Month')])
|
157
|
-
end
|
158
|
-
#=end
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_daien_lunation
|
162
|
-
sample = [
|
163
|
-
2938, 2993, 2708, 2760, 2573, 2691, 2622,
|
164
|
-
2626, 2637, 2523, 2551, 2637, 2625, 2886,
|
165
|
-
2703, 2764, 2791, 2680, 2792, 2764, 2797,
|
166
|
-
1402, 2626, 2380, 2807, 3003, 23, 2698]
|
167
|
-
|
168
|
-
%w(0765-02-01 0765-12-01 0768-09-01 0769-04-01 0769-07-01 0771-05-01 0772-04-01
|
169
|
-
0772-09-01 0774-06-01 0775-02-01 0776-03-01 0780-05-01 0781-09-01 0784-10=01
|
170
|
-
0786-03-01 0788-04-01 0791-02-01 0791-09-01 0792-05-01 0813-12-01 0816-03-01
|
171
|
-
0820-02-01 0820-03-01 0822-02-01 0835-04-01 0836-04-01 0841-11-01 0853-02-01).each do |ptn|
|
172
|
-
date = When.when?(ptn+ '^^ChineseTwin::大衍暦')
|
173
|
-
formula = date.frame.formula[-1]
|
174
|
-
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
175
|
-
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
176
|
-
assert_equal(sample.shift, (t - t.floor) * formula.denominator)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_solar_terms_for_chinese_true_lunation
|
181
|
-
date = When.when?('1690-1-1^^JapaneseTwin::貞享暦(節月)')
|
182
|
-
formula = date.frame.formula[0]
|
183
|
-
class << formula
|
184
|
-
attr_reader :day_shift, :longitude_shift, :year_delta
|
185
|
-
end
|
186
|
-
assert_equal(["12S", Rational(-1,4), 2336118.19, 1.0e-06, 1684.0, 365.241696],
|
187
|
-
[formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_delta, formula.year_epoch, formula.year_length.to_f])
|
188
|
-
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
189
|
-
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
190
|
-
# assert_equal(["1690-01-01", 2338355, 20278, [15.923047, 30.436807, 2338340.576953]],
|
191
|
-
# [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
|
192
|
-
|
193
|
-
date = When.when?('1801-1-1^^JapaneseTwin::寛政暦(節月)')
|
194
|
-
formula = date.frame.formula[0]
|
195
|
-
class << formula
|
196
|
-
attr_reader :day_epoch, :day_shift, :year_delta, :year_epoch, :year_length, :longitude_shift
|
197
|
-
end
|
198
|
-
assert_equal(["12S", Rational(-1,4), 2377390.607112, 1797.0, 365.242347071],
|
199
|
-
[formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_epoch, formula.year_length.to_f])
|
200
|
-
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
201
|
-
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
202
|
-
# assert_equal(["1801-01-01", 2378897, 21610, [15.986637, 30.436862, 2378882.513363]],
|
203
|
-
# [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
|
204
|
-
end
|
205
|
-
|
206
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011-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 MiniTest
|
10
|
+
|
11
|
+
class Chinese < MiniTest::TestCase
|
12
|
+
def test_chinese_date
|
13
|
+
|
14
|
+
emd = When.Resource('_c:EphemerisBasedSolar?time_basis=+09:00')
|
15
|
+
date = When.when?('2009-01-01', {:frame=>emd})
|
16
|
+
[
|
17
|
+
["2009-01-01", 2454867],
|
18
|
+
["2009-02-01", 2454896],
|
19
|
+
["2009-03-01", 2454927],
|
20
|
+
["2009-04-01", 2454957],
|
21
|
+
["2009-05-01", 2454988],
|
22
|
+
["2009-06-01", 2455020],
|
23
|
+
["2009-07-01", 2455051],
|
24
|
+
["2009-08-01", 2455082],
|
25
|
+
["2009-09-01", 2455113],
|
26
|
+
["2009-10-01", 2455143],
|
27
|
+
["2009-11-01", 2455173],
|
28
|
+
["2009-12-01", 2455202]
|
29
|
+
].each do |sample|
|
30
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
31
|
+
date += When.Duration('P1M')
|
32
|
+
end
|
33
|
+
|
34
|
+
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00'})
|
35
|
+
date = When.when?('2009-01-01', {:frame=>cc})
|
36
|
+
[
|
37
|
+
["2009-01-01", 2454858],
|
38
|
+
["2009-02-01", 2454888],
|
39
|
+
["2009-03-01", 2454918],
|
40
|
+
["2009-04-01", 2454947],
|
41
|
+
["2009-05-01", 2454976],
|
42
|
+
["2009-05=01", 2455006],
|
43
|
+
["2009-06-01", 2455035],
|
44
|
+
["2009-07-01", 2455064],
|
45
|
+
["2009-08-01", 2455094],
|
46
|
+
["2009-09-01", 2455123],
|
47
|
+
["2009-10-01", 2455153],
|
48
|
+
["2009-11-01", 2455182],
|
49
|
+
["2009-12-01", 2455212]
|
50
|
+
].each do |sample|
|
51
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
52
|
+
date += When.Duration('P1M')
|
53
|
+
end
|
54
|
+
|
55
|
+
date = When.when?('2032-11-01', {:frame=>cc})
|
56
|
+
[
|
57
|
+
["2032-11-01", 2463570],
|
58
|
+
["2032-12-01", 2463599],
|
59
|
+
["2033-01-01", 2463629],
|
60
|
+
["2033-02-01", 2463658],
|
61
|
+
["2033-03-01", 2463688],
|
62
|
+
["2033-04-01", 2463717],
|
63
|
+
["2033-05-01", 2463746],
|
64
|
+
["2033-06-01", 2463776],
|
65
|
+
["2033-07-01", 2463805],
|
66
|
+
["2033-08-01", 2463835],
|
67
|
+
["2033-09-01", 2463864],
|
68
|
+
["2033-10-01", 2463894],
|
69
|
+
["2033-11-01", 2463924],
|
70
|
+
["2033-11=01", 2463954],
|
71
|
+
["2033-12-01", 2463983],
|
72
|
+
["2034-01-01", 2464013],
|
73
|
+
["2034-02-01", 2464042],
|
74
|
+
["2034-03-01", 2464072]
|
75
|
+
].each do |sample|
|
76
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
77
|
+
date += When.Duration('P1M')
|
78
|
+
end
|
79
|
+
|
80
|
+
date = When.when?('2728-11-01', {:frame=>cc})
|
81
|
+
[
|
82
|
+
["2728-11-01", 2717768],
|
83
|
+
["2728-11=01", 2717798],
|
84
|
+
["2728-12-01", 2717827],
|
85
|
+
["2729-01-01", 2717857],
|
86
|
+
["2729-02-01", 2717887],
|
87
|
+
["2729-03-01", 2717916],
|
88
|
+
["2729-04-01", 2717946]
|
89
|
+
].each do |sample|
|
90
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
91
|
+
date += When.Duration('P1M')
|
92
|
+
end
|
93
|
+
|
94
|
+
cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00', 'intercalary_span'=>3})
|
95
|
+
date = When.when?('2728-11-01', {:frame=>cc})
|
96
|
+
[
|
97
|
+
["2728-11-01", 2717768],
|
98
|
+
["2728-12-01", 2717798],
|
99
|
+
["2729-01-01", 2717827],
|
100
|
+
["2729-02-01", 2717857],
|
101
|
+
["2729-02=01", 2717887],
|
102
|
+
["2729-03-01", 2717916],
|
103
|
+
["2729-04-01", 2717946]
|
104
|
+
].each do |sample|
|
105
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
106
|
+
date += When.Duration('P1M')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_chinese_epoch
|
111
|
+
date = When.when?('天保2.10.01')
|
112
|
+
assert_equal([2390126, "天保02(1831).10.01", "神無月"],
|
113
|
+
[date.to_i, date.to_s, date.name('Month')])
|
114
|
+
assert_equal("1831-11-04", (When.Calendar('Gregorian') ^ When.when?('天保02.10.01')).to_s)
|
115
|
+
|
116
|
+
#=begin
|
117
|
+
date = When.when?('天保2.10.01', {:count=>2})
|
118
|
+
assert_equal([1926999, "天保02(0563).10.01", "十月"],
|
119
|
+
[date.to_i, date.to_s, date.name('Month')])
|
120
|
+
|
121
|
+
date = When.when?('天保3(564).10.01')
|
122
|
+
assert_equal([1927353, "天保03(0564).10.01", "十月"],
|
123
|
+
[date.to_i, date.to_s, date.name('Month')])
|
124
|
+
|
125
|
+
date = When.when?('天保3.10.01', {'period'=>/梁/})
|
126
|
+
assert_equal([1927353, "天保03(0564).10.01", "十月"],
|
127
|
+
[date.to_i, date.to_s, date.name('Month')])
|
128
|
+
|
129
|
+
assert_equal(["江戸時代", "後梁", "北斉"],
|
130
|
+
When::era('天保').map {|v| v.parent.label}) # v.iri
|
131
|
+
|
132
|
+
assert_raises(ArgumentError) { When.when?('天保3(0563).10.01') }
|
133
|
+
|
134
|
+
date = When.when?('始皇帝26*10.01')
|
135
|
+
assert_equal([1640641, "始皇帝26(-220)*10.01", "十月"],
|
136
|
+
[date.to_i, date.to_s, date.name('Month')])
|
137
|
+
|
138
|
+
cc_221 = When.Resource('_c:Chinese_221')
|
139
|
+
[
|
140
|
+
["-220*10-01", 1640641, "-00220*10-01", "十月"],
|
141
|
+
["-220*11-01", 1640671, "-00220*11-01", "十一月"],
|
142
|
+
["-220*12-01", 1640700, "-00220*12-01", "十二月"],
|
143
|
+
["-220-01-01", 1640730, "-00220-01-01", "正月"],
|
144
|
+
["-220-02-01", 1640759, "-00220-02-01", "二月"],
|
145
|
+
["-220-03-01", 1640789, "-00220-03-01", "三月"],
|
146
|
+
["-220-04-01", 1640818, "-00220-04-01", "四月"],
|
147
|
+
["-220-05-01", 1640848, "-00220-05-01", "五月"],
|
148
|
+
["-220-06-01", 1640877, "-00220-06-01", "六月"],
|
149
|
+
["-220-07-01", 1640907, "-00220-07-01", "七月"],
|
150
|
+
["-220-08-01", 1640937, "-00220-08-01", "八月"],
|
151
|
+
["-220-09-01", 1640966, "-00220-09-01", "九月"],
|
152
|
+
["-220-09=01", 1640996, "-00220-09=01", "閏九月"]
|
153
|
+
].each do |sample|
|
154
|
+
date = When.when?(sample[0], {:frame=>cc_221})
|
155
|
+
assert_equal(sample[1..-1],
|
156
|
+
[date.to_i, date.to_s, date.name('Month')])
|
157
|
+
end
|
158
|
+
#=end
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_daien_lunation
|
162
|
+
sample = [
|
163
|
+
2938, 2993, 2708, 2760, 2573, 2691, 2622,
|
164
|
+
2626, 2637, 2523, 2551, 2637, 2625, 2886,
|
165
|
+
2703, 2764, 2791, 2680, 2792, 2764, 2797,
|
166
|
+
1402, 2626, 2380, 2807, 3003, 23, 2698]
|
167
|
+
|
168
|
+
%w(0765-02-01 0765-12-01 0768-09-01 0769-04-01 0769-07-01 0771-05-01 0772-04-01
|
169
|
+
0772-09-01 0774-06-01 0775-02-01 0776-03-01 0780-05-01 0781-09-01 0784-10=01
|
170
|
+
0786-03-01 0788-04-01 0791-02-01 0791-09-01 0792-05-01 0813-12-01 0816-03-01
|
171
|
+
0820-02-01 0820-03-01 0822-02-01 0835-04-01 0836-04-01 0841-11-01 0853-02-01).each do |ptn|
|
172
|
+
date = When.when?(ptn+ '^^ChineseTwin::大衍暦')
|
173
|
+
formula = date.frame.formula[-1]
|
174
|
+
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
175
|
+
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
176
|
+
assert_equal(sample.shift, (t - t.floor) * formula.denominator)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_solar_terms_for_chinese_true_lunation
|
181
|
+
date = When.when?('1690-1-1^^JapaneseTwin::貞享暦(節月)')
|
182
|
+
formula = date.frame.formula[0]
|
183
|
+
class << formula
|
184
|
+
attr_reader :day_shift, :longitude_shift, :year_delta
|
185
|
+
end
|
186
|
+
assert_equal(["12S", Rational(-1,4), 2336118.19, 1.0e-06, 1684.0, 365.241696],
|
187
|
+
[formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_delta, formula.year_epoch, formula.year_length.to_f])
|
188
|
+
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
189
|
+
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
190
|
+
# assert_equal(["1690-01-01", 2338355, 20278, [15.923047, 30.436807, 2338340.576953]],
|
191
|
+
# [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
|
192
|
+
|
193
|
+
date = When.when?('1801-1-1^^JapaneseTwin::寛政暦(節月)')
|
194
|
+
formula = date.frame.formula[0]
|
195
|
+
class << formula
|
196
|
+
attr_reader :day_epoch, :day_shift, :year_delta, :year_epoch, :year_length, :longitude_shift
|
197
|
+
end
|
198
|
+
assert_equal(["12S", Rational(-1,4), 2377390.607112, 1797.0, 365.242347071],
|
199
|
+
[formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_epoch, formula.year_length.to_f])
|
200
|
+
m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
|
201
|
+
t = formula.cn_to_time(m[0]) + Rational(1,2)
|
202
|
+
# assert_equal(["1801-01-01", 2378897, 21610, [15.986637, 30.436862, 2378882.513363]],
|
203
|
+
# [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_chinese_era
|
207
|
+
assert_equal("慶元03(1197).01.10", When.when?('慶元3.1.10').to_s) # , {'period'=>/清/})
|
208
|
+
assert_equal("紹熙03(1192).01.10", When.when?('紹煕3.1.10').to_s) # , {'period'=>/清/})
|
209
|
+
assert_equal("康熙03(1664).01.10", When.when?('康煕3.1.10').to_s) # , {'period'=>/清/})
|
210
|
+
assert_equal("紹熙03(1192).01.10", When.when?('紹熙3.1.10').to_s) # , {'period'=>/清/})
|
211
|
+
assert_equal("崇徳03(1638).01.30", When.when?('崇徳3.1.30', {'period'=>/清/}).to_s)
|
212
|
+
assert_raises(ArgumentError) {When.when?('崇徳3.1.30', {'period'=>/後金/})}
|
213
|
+
assert_equal("正徳16(1521).03.14", When.TemporalPosition("正徳", 16, 3, 14, {"period"=>/明/}).to_s)
|
214
|
+
assert_equal("正徳16(1521).03.14", When.when?('正徳16.3.14', {'period'=>/明/}).to_s)
|
215
|
+
assert_equal("明::崇禎11(1638).01.30", When.when?('崇禎11.1.30', {'period'=>/明/}).to_s)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|