when_exe 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -23
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/linkeddata.rb +0 -1
- data/lib/when_exe/locales/encoding_conversion.rb +134 -134
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/parts/method_cash.rb +224 -224
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/geologicalage.rb +1 -1
- data/lib/when_exe/region/japanese/calendars.rb +397 -397
- data/lib/when_exe/region/japanese/eclipses.rb +1194 -1194
- data/lib/when_exe/region/japanese/nihon_shoki.rb +70 -70
- data/lib/when_exe/region/korean.rb +384 -384
- data/lib/when_exe/region/ryukyu.rb +101 -101
- data/lib/when_exe/tmposition.rb +2 -2
- data/lib/when_exe/tmreference.rb +3 -3
- data/lib/when_exe/version.rb +1 -1
- data/test/scripts/geometric_complex.rb +41 -41
- data/test/scripts/korea.rb +59 -59
- data/test/scripts/thai.rb +36 -36
- data/test/test/basictypes.rb +431 -431
- data/test/test/calendarnote.rb +86 -86
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +397 -397
- data/test/test/ephemeris.rb +115 -115
- 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/inspect.rb +153 -153
- data/test/test/parts.rb +488 -488
- data/test/test/region/armenian.rb +20 -20
- data/test/test/region/bahai.rb +58 -58
- data/test/test/region/balinese.rb +34 -34
- data/test/test/region/chinese.rb +229 -229
- data/test/test/region/christian.rb +226 -226
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/discordian.rb +20 -20
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +54 -54
- data/test/test/region/japanese.rb +261 -261
- data/test/test/region/jewish.rb +63 -63
- data/test/test/region/shire.rb +58 -58
- data/test/test/region/swedish.rb +45 -45
- 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/zoroastrian.rb +58 -58
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +402 -402
- data/test/test/tmreference.rb +157 -157
- metadata +4 -88
@@ -1,226 +1,226 @@
|
|
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 MiniTest
|
10
|
-
|
11
|
-
class ChristianVariation < MiniTest::TestCase
|
12
|
-
|
13
|
-
def verify_built_in_date(calendar, start, length)
|
14
|
-
date = Date.new(start, 1, 1)
|
15
|
-
diff = {}
|
16
|
-
while date.year < start + length
|
17
|
-
cal_date = [date.year, date.month, date.day]
|
18
|
-
cal_jdn = date.jd
|
19
|
-
fdate = When.TemporalPosition(date.year, date.month, date.day, {:frame=>calendar})
|
20
|
-
rdate = calendar ^ cal_jdn
|
21
|
-
[fdate, rdate].each do |tdate|
|
22
|
-
[[cal_date, tdate.cal_date], [cal_jdn, tdate.to_i]].each do |verify|
|
23
|
-
unless verify.uniq.size == 1
|
24
|
-
diff[cal_date] ||= []
|
25
|
-
diff[cal_date] << verify[1]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
date = yield(date)
|
30
|
-
end
|
31
|
-
diff
|
32
|
-
end
|
33
|
-
|
34
|
-
def test__verify_to_built_in_date
|
35
|
-
|
36
|
-
sample = [{}, {}, {}, {}, {}, {[2900, 1, 1]=>[2780263, [2900, 1, 2]]}]
|
37
|
-
|
38
|
-
%w(Gregorian RevisedJulian).each do |name|
|
39
|
-
calendar = When.Calendar(name)
|
40
|
-
assert_equal(sample.shift, verify_built_in_date(calendar, 1900, 8) {|date| date + 1})
|
41
|
-
assert_equal(sample.shift, verify_built_in_date(calendar, 2000,400) {|date| date >> 1})
|
42
|
-
assert_equal(sample.shift, verify_built_in_date(calendar, 2400,900) {|date| date >> 1200})
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test__gregorian_date
|
47
|
-
|
48
|
-
calendar = When.Calendar('Gregorian')
|
49
|
-
|
50
|
-
dates = [When.when?('1900-02-28', {:frame=>calendar})]
|
51
|
-
9.times do
|
52
|
-
dates << dates.last + When::P1Y * 100
|
53
|
-
end
|
54
|
-
assert_equal([2415079, 2451603, 2488128, 2524652, 2561176,
|
55
|
-
2597700, 2634225, 2670749, 2707273, 2743797], dates.map {|date| date.to_i})
|
56
|
-
assert_equal(%w(1900-02-28 2000-02-28 2100-02-28 2200-02-28 2300-02-28
|
57
|
-
2400-02-28 2500-02-28 2600-02-28 2700-02-28 2800-02-28), dates.map {|date| (calendar ^ date.to_i).to_s})
|
58
|
-
assert_equal([28, 29, 28, 28, 28, 29, 28, 28, 28, 29], dates.map {|date| date.length(When::MONTH)})
|
59
|
-
|
60
|
-
dates = [When.when?('1900-03-01', {:frame=>calendar})]
|
61
|
-
9.times do
|
62
|
-
dates << dates.last + When::P1Y * 100
|
63
|
-
end
|
64
|
-
assert_equal([2415080, 2451605, 2488129, 2524653, 2561177,
|
65
|
-
2597702, 2634226, 2670750, 2707274, 2743799], dates.map {|date| date.to_i})
|
66
|
-
assert_equal(%w(1900-03-01 2000-03-01 2100-03-01 2200-03-01 2300-03-01
|
67
|
-
2400-03-01 2500-03-01 2600-03-01 2700-03-01 2800-03-01), dates.map {|date| (calendar ^ date.to_i).to_s})
|
68
|
-
assert_equal([1], dates.map {|date| calendar._century_from_jdn(date.to_i) - calendar._century_from_jdn(date.to_i-1)}.uniq)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test__revised_julian_date
|
72
|
-
|
73
|
-
calendar = When.Calendar('RevisedJulian')
|
74
|
-
|
75
|
-
dates = [When.when?('1900-02-28', {:frame=>calendar})]
|
76
|
-
9.times do
|
77
|
-
dates << dates.last + When::P1Y * 100
|
78
|
-
end
|
79
|
-
assert_equal([2415079, 2451603, 2488128, 2524652, 2561176,
|
80
|
-
2597700, 2634225, 2670749, 2707273, 2743797], dates.map {|date| date.to_i})
|
81
|
-
assert_equal(%w(1900-02-28 2000-02-28 2100-02-28 2200-02-28 2300-02-28
|
82
|
-
2400-02-28 2500-02-28 2600-02-28 2700-02-28 2800-02-28), dates.map {|date| (calendar ^ date.to_i).to_s})
|
83
|
-
assert_equal([28, 29, 28, 28, 28, 29, 28, 28, 28, 28], dates.map {|date| date.length(When::MONTH)})
|
84
|
-
|
85
|
-
dates = [When.when?('1900-03-01', {:frame=>calendar})]
|
86
|
-
9.times do
|
87
|
-
dates << dates.last + When::P1Y * 100
|
88
|
-
end
|
89
|
-
assert_equal([2415080, 2451605, 2488129, 2524653, 2561177,
|
90
|
-
2597702, 2634226, 2670750, 2707274, 2743798], dates.map {|date| date.to_i})
|
91
|
-
assert_equal(%w(1900-03-01 2000-03-01 2100-03-01 2200-03-01 2300-03-01
|
92
|
-
2400-03-01 2500-03-01 2600-03-01 2700-03-01 2800-03-01), dates.map {|date| (calendar ^ date.to_i).to_s})
|
93
|
-
assert_equal([1], dates.map {|date| calendar._century_from_jdn(date.to_i) - calendar._century_from_jdn(date.to_i-1)}.uniq)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class Civil < MiniTest::TestCase
|
98
|
-
def test__border
|
99
|
-
frame = When.Calendar('Civil?reform=1752-9-14&border=0-3-25(1753)0-1-1')
|
100
|
-
assert_equal("1641=03-24", (frame ^ When.when?('1642-4-3') ).to_s)
|
101
|
-
assert_equal("1642-03-25", (frame ^ When.when?('1642-4-4') ).to_s)
|
102
|
-
assert_equal("1752-12-31", (frame ^ When.when?('1752-12-31')).to_s)
|
103
|
-
assert_equal("1753-01-01", (frame ^ When.when?('1753-1-1') ).to_s)
|
104
|
-
assert_equal("1753-03-24", (frame ^ When.when?('1753-3-24') ).to_s)
|
105
|
-
assert_equal("1753-03-25", (frame ^ When.when?('1753-3-25') ).to_s)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test__reform_inc
|
109
|
-
sample = %w(
|
110
|
-
1582-09-30 1582-10-01 1582-10-02 1582-10-03 1582-10-04 1582-10-15 1582-10-16 1582-10-17
|
111
|
-
1582-10-18 1582-10-19 1582-10-20 1582-10-21 1582-10-22 1582-10-23 1582-10-24 1582-10-25
|
112
|
-
1582-10-26 1582-10-27 1582-10-28 1582-10-29 1582-10-30 1582-10-31 1582-11-01 1582-11-02
|
113
|
-
1582-11-03)
|
114
|
-
date = When.when?('1582-9-30', :frame=>'Civil?reform=1582-10-15')
|
115
|
-
25.times do
|
116
|
-
assert_equal(sample.shift, date.to_s)
|
117
|
-
date = date + When::P1D
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def test__reform_dec
|
122
|
-
sample = %w(
|
123
|
-
1582-11-01 1582-10-31 1582-10-30 1582-10-29 1582-10-28 1582-10-27 1582-10-26 1582-10-25
|
124
|
-
1582-10-24 1582-10-23 1582-10-22 1582-10-21 1582-10-20 1582-10-19 1582-10-18 1582-10-17
|
125
|
-
1582-10-16 1582-10-15 1582-10-04 1582-10-03 1582-10-02 1582-10-01 1582-09-30 1582-09-29
|
126
|
-
1582-09-28)
|
127
|
-
date = When.when?('1582-11-01', :frame=>'Civil?reform=1582-10-15')
|
128
|
-
25.times do
|
129
|
-
assert_equal(sample.shift, date.to_s)
|
130
|
-
date = date - When::P1D
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_civil_epoch
|
135
|
-
epoch = 1001
|
136
|
-
diff = 1 - epoch
|
137
|
-
civil = When.Calendar("Civil?origin_of_MSC=#{diff}&old=(Julian?origin_of_MSC=#{diff})")
|
138
|
-
assert_equal('0582-10-04', (civil ^ When.when?('1582-10-14')).to_s)
|
139
|
-
assert_equal('0582-10-15', (civil ^ When.when?('1582-10-15')).to_s)
|
140
|
-
date = When.when?("1000-1-1", :frame=>civil)
|
141
|
-
assert_equal('1014-01-01', (date & When.Residue('甲午').to('year')).to_s)
|
142
|
-
assert_equal(%w(1000-01-01 2000-01-01), [date.to_s, (When::Gregorian^date).to_s])
|
143
|
-
399.times do
|
144
|
-
date += When::P1Y
|
145
|
-
cal_date = date.cal_date
|
146
|
-
assert_equal((When::Gregorian^date).cal_date, [cal_date[0]-diff] + cal_date[1..2])
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def test__reform_year
|
151
|
-
date = When.when?('1752^^Civil?reform=1752-9-14&border=(1000)0-3-25(1753)0-1-1')
|
152
|
-
assert_equal(
|
153
|
-
[[1752,
|
154
|
-
[[3,
|
155
|
-
["*", 1, 2, 3, 4, 5, 6, 7],
|
156
|
-
["*", 8, 9, 10, 11, 12, 13, 14],
|
157
|
-
["*", 15, 16, 17, 18, 19, 20, 21],
|
158
|
-
["*", 22, 23, 24, 25, 26, 27, 28],
|
159
|
-
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
160
|
-
[[4,
|
161
|
-
["*", "*", "*", "*", 1, 2, 3, 4],
|
162
|
-
["*", 5, 6, 7, 8, 9, 10, 11],
|
163
|
-
["*", 12, 13, 14, 15, 16, 17, 18],
|
164
|
-
["*", 19, 20, 21, 22, 23, 24, 25],
|
165
|
-
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
166
|
-
[[5,
|
167
|
-
["*", "*", "*", "*", "*", "*", 1, 2],
|
168
|
-
["*", 3, 4, 5, 6, 7, 8, 9],
|
169
|
-
["*", 10, 11, 12, 13, 14, 15, 16],
|
170
|
-
["*", 17, 18, 19, 20, 21, 22, 23],
|
171
|
-
["*", 24, 25, 26, 27, 28, 29, 30],
|
172
|
-
["*", 31, "*", "*", "*", "*", "*", "*"]]],
|
173
|
-
[[6,
|
174
|
-
["*", "*", 1, 2, 3, 4, 5, 6],
|
175
|
-
["*", 7, 8, 9, 10, 11, 12, 13],
|
176
|
-
["*", 14, 15, 16, 17, 18, 19, 20],
|
177
|
-
["*", 21, 22, 23, 24, 25, 26, 27],
|
178
|
-
["*", 28, 29, 30, "*", "*", "*", "*"]]],
|
179
|
-
[[7,
|
180
|
-
["*", "*", "*", "*", 1, 2, 3, 4],
|
181
|
-
["*", 5, 6, 7, 8, 9, 10, 11],
|
182
|
-
["*", 12, 13, 14, 15, 16, 17, 18],
|
183
|
-
["*", 19, 20, 21, 22, 23, 24, 25],
|
184
|
-
["*", 26, 27, 28, 29, 30, 31, "*"]]],
|
185
|
-
[[8,
|
186
|
-
["*", "*", "*", "*", "*", "*", "*", 1],
|
187
|
-
["*", 2, 3, 4, 5, 6, 7, 8],
|
188
|
-
["*", 9, 10, 11, 12, 13, 14, 15],
|
189
|
-
["*", 16, 17, 18, 19, 20, 21, 22],
|
190
|
-
["*", 23, 24, 25, 26, 27, 28, 29],
|
191
|
-
["*", 30, 31, "*", "*", "*", "*", "*"]]],
|
192
|
-
[[9,
|
193
|
-
["*", "*", "*", 1, 2, 14, 15, 16],
|
194
|
-
["*", 17, 18, 19, 20, 21, 22, 23],
|
195
|
-
["*", 24, 25, 26, 27, 28, 29, 30]]],
|
196
|
-
[[10,
|
197
|
-
["*", 1, 2, 3, 4, 5, 6, 7],
|
198
|
-
["*", 8, 9, 10, 11, 12, 13, 14],
|
199
|
-
["*", 15, 16, 17, 18, 19, 20, 21],
|
200
|
-
["*", 22, 23, 24, 25, 26, 27, 28],
|
201
|
-
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
202
|
-
[[11,
|
203
|
-
["*", "*", "*", "*", 1, 2, 3, 4],
|
204
|
-
["*", 5, 6, 7, 8, 9, 10, 11],
|
205
|
-
["*", 12, 13, 14, 15, 16, 17, 18],
|
206
|
-
["*", 19, 20, 21, 22, 23, 24, 25],
|
207
|
-
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
208
|
-
[[12,
|
209
|
-
["*", "*", "*", "*", "*", "*", 1, 2],
|
210
|
-
["*", 3, 4, 5, 6, 7, 8, 9],
|
211
|
-
["*", 10, 11, 12, 13, 14, 15, 16],
|
212
|
-
["*", 17, 18, 19, 20, 21, 22, 23],
|
213
|
-
["*", 24, 25, 26, 27, 28, 29, 30],
|
214
|
-
["*", 31, "*", "*", "*", "*", "*", "*"]]]]],
|
215
|
-
date.year_included('Sunday') {|d,b|
|
216
|
-
case b
|
217
|
-
when When::YEAR ; d[When::YEAR]
|
218
|
-
when When::MONTH ; d[When::MONTH]
|
219
|
-
when When::DAY ; d[When::DAY]
|
220
|
-
else ; '*'
|
221
|
-
end
|
222
|
-
}
|
223
|
-
)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
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 MiniTest
|
10
|
+
|
11
|
+
class ChristianVariation < MiniTest::TestCase
|
12
|
+
|
13
|
+
def verify_built_in_date(calendar, start, length)
|
14
|
+
date = Date.new(start, 1, 1)
|
15
|
+
diff = {}
|
16
|
+
while date.year < start + length
|
17
|
+
cal_date = [date.year, date.month, date.day]
|
18
|
+
cal_jdn = date.jd
|
19
|
+
fdate = When.TemporalPosition(date.year, date.month, date.day, {:frame=>calendar})
|
20
|
+
rdate = calendar ^ cal_jdn
|
21
|
+
[fdate, rdate].each do |tdate|
|
22
|
+
[[cal_date, tdate.cal_date], [cal_jdn, tdate.to_i]].each do |verify|
|
23
|
+
unless verify.uniq.size == 1
|
24
|
+
diff[cal_date] ||= []
|
25
|
+
diff[cal_date] << verify[1]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
date = yield(date)
|
30
|
+
end
|
31
|
+
diff
|
32
|
+
end
|
33
|
+
|
34
|
+
def test__verify_to_built_in_date
|
35
|
+
|
36
|
+
sample = [{}, {}, {}, {}, {}, {[2900, 1, 1]=>[2780263, [2900, 1, 2]]}]
|
37
|
+
|
38
|
+
%w(Gregorian RevisedJulian).each do |name|
|
39
|
+
calendar = When.Calendar(name)
|
40
|
+
assert_equal(sample.shift, verify_built_in_date(calendar, 1900, 8) {|date| date + 1})
|
41
|
+
assert_equal(sample.shift, verify_built_in_date(calendar, 2000,400) {|date| date >> 1})
|
42
|
+
assert_equal(sample.shift, verify_built_in_date(calendar, 2400,900) {|date| date >> 1200})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test__gregorian_date
|
47
|
+
|
48
|
+
calendar = When.Calendar('Gregorian')
|
49
|
+
|
50
|
+
dates = [When.when?('1900-02-28', {:frame=>calendar})]
|
51
|
+
9.times do
|
52
|
+
dates << dates.last + When::P1Y * 100
|
53
|
+
end
|
54
|
+
assert_equal([2415079, 2451603, 2488128, 2524652, 2561176,
|
55
|
+
2597700, 2634225, 2670749, 2707273, 2743797], dates.map {|date| date.to_i})
|
56
|
+
assert_equal(%w(1900-02-28 2000-02-28 2100-02-28 2200-02-28 2300-02-28
|
57
|
+
2400-02-28 2500-02-28 2600-02-28 2700-02-28 2800-02-28), dates.map {|date| (calendar ^ date.to_i).to_s})
|
58
|
+
assert_equal([28, 29, 28, 28, 28, 29, 28, 28, 28, 29], dates.map {|date| date.length(When::MONTH)})
|
59
|
+
|
60
|
+
dates = [When.when?('1900-03-01', {:frame=>calendar})]
|
61
|
+
9.times do
|
62
|
+
dates << dates.last + When::P1Y * 100
|
63
|
+
end
|
64
|
+
assert_equal([2415080, 2451605, 2488129, 2524653, 2561177,
|
65
|
+
2597702, 2634226, 2670750, 2707274, 2743799], dates.map {|date| date.to_i})
|
66
|
+
assert_equal(%w(1900-03-01 2000-03-01 2100-03-01 2200-03-01 2300-03-01
|
67
|
+
2400-03-01 2500-03-01 2600-03-01 2700-03-01 2800-03-01), dates.map {|date| (calendar ^ date.to_i).to_s})
|
68
|
+
assert_equal([1], dates.map {|date| calendar._century_from_jdn(date.to_i) - calendar._century_from_jdn(date.to_i-1)}.uniq)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test__revised_julian_date
|
72
|
+
|
73
|
+
calendar = When.Calendar('RevisedJulian')
|
74
|
+
|
75
|
+
dates = [When.when?('1900-02-28', {:frame=>calendar})]
|
76
|
+
9.times do
|
77
|
+
dates << dates.last + When::P1Y * 100
|
78
|
+
end
|
79
|
+
assert_equal([2415079, 2451603, 2488128, 2524652, 2561176,
|
80
|
+
2597700, 2634225, 2670749, 2707273, 2743797], dates.map {|date| date.to_i})
|
81
|
+
assert_equal(%w(1900-02-28 2000-02-28 2100-02-28 2200-02-28 2300-02-28
|
82
|
+
2400-02-28 2500-02-28 2600-02-28 2700-02-28 2800-02-28), dates.map {|date| (calendar ^ date.to_i).to_s})
|
83
|
+
assert_equal([28, 29, 28, 28, 28, 29, 28, 28, 28, 28], dates.map {|date| date.length(When::MONTH)})
|
84
|
+
|
85
|
+
dates = [When.when?('1900-03-01', {:frame=>calendar})]
|
86
|
+
9.times do
|
87
|
+
dates << dates.last + When::P1Y * 100
|
88
|
+
end
|
89
|
+
assert_equal([2415080, 2451605, 2488129, 2524653, 2561177,
|
90
|
+
2597702, 2634226, 2670750, 2707274, 2743798], dates.map {|date| date.to_i})
|
91
|
+
assert_equal(%w(1900-03-01 2000-03-01 2100-03-01 2200-03-01 2300-03-01
|
92
|
+
2400-03-01 2500-03-01 2600-03-01 2700-03-01 2800-03-01), dates.map {|date| (calendar ^ date.to_i).to_s})
|
93
|
+
assert_equal([1], dates.map {|date| calendar._century_from_jdn(date.to_i) - calendar._century_from_jdn(date.to_i-1)}.uniq)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class Civil < MiniTest::TestCase
|
98
|
+
def test__border
|
99
|
+
frame = When.Calendar('Civil?reform=1752-9-14&border=0-3-25(1753)0-1-1')
|
100
|
+
assert_equal("1641=03-24", (frame ^ When.when?('1642-4-3') ).to_s)
|
101
|
+
assert_equal("1642-03-25", (frame ^ When.when?('1642-4-4') ).to_s)
|
102
|
+
assert_equal("1752-12-31", (frame ^ When.when?('1752-12-31')).to_s)
|
103
|
+
assert_equal("1753-01-01", (frame ^ When.when?('1753-1-1') ).to_s)
|
104
|
+
assert_equal("1753-03-24", (frame ^ When.when?('1753-3-24') ).to_s)
|
105
|
+
assert_equal("1753-03-25", (frame ^ When.when?('1753-3-25') ).to_s)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test__reform_inc
|
109
|
+
sample = %w(
|
110
|
+
1582-09-30 1582-10-01 1582-10-02 1582-10-03 1582-10-04 1582-10-15 1582-10-16 1582-10-17
|
111
|
+
1582-10-18 1582-10-19 1582-10-20 1582-10-21 1582-10-22 1582-10-23 1582-10-24 1582-10-25
|
112
|
+
1582-10-26 1582-10-27 1582-10-28 1582-10-29 1582-10-30 1582-10-31 1582-11-01 1582-11-02
|
113
|
+
1582-11-03)
|
114
|
+
date = When.when?('1582-9-30', :frame=>'Civil?reform=1582-10-15')
|
115
|
+
25.times do
|
116
|
+
assert_equal(sample.shift, date.to_s)
|
117
|
+
date = date + When::P1D
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def test__reform_dec
|
122
|
+
sample = %w(
|
123
|
+
1582-11-01 1582-10-31 1582-10-30 1582-10-29 1582-10-28 1582-10-27 1582-10-26 1582-10-25
|
124
|
+
1582-10-24 1582-10-23 1582-10-22 1582-10-21 1582-10-20 1582-10-19 1582-10-18 1582-10-17
|
125
|
+
1582-10-16 1582-10-15 1582-10-04 1582-10-03 1582-10-02 1582-10-01 1582-09-30 1582-09-29
|
126
|
+
1582-09-28)
|
127
|
+
date = When.when?('1582-11-01', :frame=>'Civil?reform=1582-10-15')
|
128
|
+
25.times do
|
129
|
+
assert_equal(sample.shift, date.to_s)
|
130
|
+
date = date - When::P1D
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_civil_epoch
|
135
|
+
epoch = 1001
|
136
|
+
diff = 1 - epoch
|
137
|
+
civil = When.Calendar("Civil?origin_of_MSC=#{diff}&old=(Julian?origin_of_MSC=#{diff})")
|
138
|
+
assert_equal('0582-10-04', (civil ^ When.when?('1582-10-14')).to_s)
|
139
|
+
assert_equal('0582-10-15', (civil ^ When.when?('1582-10-15')).to_s)
|
140
|
+
date = When.when?("1000-1-1", :frame=>civil)
|
141
|
+
assert_equal('1014-01-01', (date & When.Residue('甲午').to('year')).to_s)
|
142
|
+
assert_equal(%w(1000-01-01 2000-01-01), [date.to_s, (When::Gregorian^date).to_s])
|
143
|
+
399.times do
|
144
|
+
date += When::P1Y
|
145
|
+
cal_date = date.cal_date
|
146
|
+
assert_equal((When::Gregorian^date).cal_date, [cal_date[0]-diff] + cal_date[1..2])
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def test__reform_year
|
151
|
+
date = When.when?('1752^^Civil?reform=1752-9-14&border=(1000)0-3-25(1753)0-1-1')
|
152
|
+
assert_equal(
|
153
|
+
[[1752,
|
154
|
+
[[3,
|
155
|
+
["*", 1, 2, 3, 4, 5, 6, 7],
|
156
|
+
["*", 8, 9, 10, 11, 12, 13, 14],
|
157
|
+
["*", 15, 16, 17, 18, 19, 20, 21],
|
158
|
+
["*", 22, 23, 24, 25, 26, 27, 28],
|
159
|
+
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
160
|
+
[[4,
|
161
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
162
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
163
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
164
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
165
|
+
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
166
|
+
[[5,
|
167
|
+
["*", "*", "*", "*", "*", "*", 1, 2],
|
168
|
+
["*", 3, 4, 5, 6, 7, 8, 9],
|
169
|
+
["*", 10, 11, 12, 13, 14, 15, 16],
|
170
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
171
|
+
["*", 24, 25, 26, 27, 28, 29, 30],
|
172
|
+
["*", 31, "*", "*", "*", "*", "*", "*"]]],
|
173
|
+
[[6,
|
174
|
+
["*", "*", 1, 2, 3, 4, 5, 6],
|
175
|
+
["*", 7, 8, 9, 10, 11, 12, 13],
|
176
|
+
["*", 14, 15, 16, 17, 18, 19, 20],
|
177
|
+
["*", 21, 22, 23, 24, 25, 26, 27],
|
178
|
+
["*", 28, 29, 30, "*", "*", "*", "*"]]],
|
179
|
+
[[7,
|
180
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
181
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
182
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
183
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
184
|
+
["*", 26, 27, 28, 29, 30, 31, "*"]]],
|
185
|
+
[[8,
|
186
|
+
["*", "*", "*", "*", "*", "*", "*", 1],
|
187
|
+
["*", 2, 3, 4, 5, 6, 7, 8],
|
188
|
+
["*", 9, 10, 11, 12, 13, 14, 15],
|
189
|
+
["*", 16, 17, 18, 19, 20, 21, 22],
|
190
|
+
["*", 23, 24, 25, 26, 27, 28, 29],
|
191
|
+
["*", 30, 31, "*", "*", "*", "*", "*"]]],
|
192
|
+
[[9,
|
193
|
+
["*", "*", "*", 1, 2, 14, 15, 16],
|
194
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
195
|
+
["*", 24, 25, 26, 27, 28, 29, 30]]],
|
196
|
+
[[10,
|
197
|
+
["*", 1, 2, 3, 4, 5, 6, 7],
|
198
|
+
["*", 8, 9, 10, 11, 12, 13, 14],
|
199
|
+
["*", 15, 16, 17, 18, 19, 20, 21],
|
200
|
+
["*", 22, 23, 24, 25, 26, 27, 28],
|
201
|
+
["*", 29, 30, 31, "*", "*", "*", "*"]]],
|
202
|
+
[[11,
|
203
|
+
["*", "*", "*", "*", 1, 2, 3, 4],
|
204
|
+
["*", 5, 6, 7, 8, 9, 10, 11],
|
205
|
+
["*", 12, 13, 14, 15, 16, 17, 18],
|
206
|
+
["*", 19, 20, 21, 22, 23, 24, 25],
|
207
|
+
["*", 26, 27, 28, 29, 30, "*", "*"]]],
|
208
|
+
[[12,
|
209
|
+
["*", "*", "*", "*", "*", "*", 1, 2],
|
210
|
+
["*", 3, 4, 5, 6, 7, 8, 9],
|
211
|
+
["*", 10, 11, 12, 13, 14, 15, 16],
|
212
|
+
["*", 17, 18, 19, 20, 21, 22, 23],
|
213
|
+
["*", 24, 25, 26, 27, 28, 29, 30],
|
214
|
+
["*", 31, "*", "*", "*", "*", "*", "*"]]]]],
|
215
|
+
date.year_included('Sunday') {|d,b|
|
216
|
+
case b
|
217
|
+
when When::YEAR ; d[When::YEAR]
|
218
|
+
when When::MONTH ; d[When::MONTH]
|
219
|
+
when When::DAY ; d[When::DAY]
|
220
|
+
else ; '*'
|
221
|
+
end
|
222
|
+
}
|
223
|
+
)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
data/test/test/region/coptic.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 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 Coptic < MiniTest::TestCase
|
12
|
-
def test__coptic
|
13
|
-
julian = When.Calendar('Julian')
|
14
|
-
gregorian = When.Calendar('Gregorian')
|
15
|
-
ethiopian = When.Calendar('Coptic?Epoch=8Y')
|
16
|
-
egyptian = When.Calendar('Coptic?Epoch=284Y')
|
17
|
-
|
18
|
-
[['2010-8-29', %w(2010-08-29 2010-09-11 2003-01-01 1727-01-01)],
|
19
|
-
['2011-8-30', %w(2011-08-30 2011-09-12 2004-01-01 1728-01-01)],
|
20
|
-
['2012-8-29', %w(2012-08-29 2012-09-11 2005-01-01 1729-01-01)],
|
21
|
-
['2013-8-29', %w(2013-08-29 2013-09-11 2006-01-01 1730-01-01)]].each do |sample|
|
22
|
-
date = When.when?(sample[0], :frame=>julian)
|
23
|
-
assert_equal(sample[1], [date.to_s, (gregorian ^ date).to_s, (ethiopian ^ date).to_s, (egyptian ^ date).to_s])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 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 Coptic < MiniTest::TestCase
|
12
|
+
def test__coptic
|
13
|
+
julian = When.Calendar('Julian')
|
14
|
+
gregorian = When.Calendar('Gregorian')
|
15
|
+
ethiopian = When.Calendar('Coptic?Epoch=8Y')
|
16
|
+
egyptian = When.Calendar('Coptic?Epoch=284Y')
|
17
|
+
|
18
|
+
[['2010-8-29', %w(2010-08-29 2010-09-11 2003-01-01 1727-01-01)],
|
19
|
+
['2011-8-30', %w(2011-08-30 2011-09-12 2004-01-01 1728-01-01)],
|
20
|
+
['2012-8-29', %w(2012-08-29 2012-09-11 2005-01-01 1729-01-01)],
|
21
|
+
['2013-8-29', %w(2013-08-29 2013-09-11 2006-01-01 1730-01-01)]].each do |sample|
|
22
|
+
date = When.when?(sample[0], :frame=>julian)
|
23
|
+
assert_equal(sample[1], [date.to_s, (gregorian ^ date).to_s, (ethiopian ^ date).to_s, (egyptian ^ date).to_s])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|