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
data/test/test/region/jewish.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
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 Jewish < MiniTest::TestCase
|
12
|
-
def test__jewish
|
13
|
-
date = When.when? 'HY5700.1.1'
|
14
|
-
[["HY5700.01.01", 2429521],
|
15
|
-
["HY5700.02.01", 2429551],
|
16
|
-
["HY5700.03.01", 2429581],
|
17
|
-
["HY5700.04.01", 2429611],
|
18
|
-
["HY5700.05.01", 2429640],
|
19
|
-
["HY5700.06*01", 2429670],
|
20
|
-
["HY5700.06=01", 2429700],
|
21
|
-
["HY5700.07.01", 2429729],
|
22
|
-
["HY5700.08.01", 2429759],
|
23
|
-
["HY5700.09.01", 2429788],
|
24
|
-
["HY5700.10.01", 2429818],
|
25
|
-
["HY5700.11.01", 2429847],
|
26
|
-
["HY5700.12.01", 2429877]].each do |sample|
|
27
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
28
|
-
date += When.Duration('P1M')
|
29
|
-
end
|
30
|
-
|
31
|
-
date = When.when? 'HY5773.1.1'
|
32
|
-
[["HY5773.01.01", 2456188],
|
33
|
-
["HY5774.01.01", 2456541],
|
34
|
-
["HY5775.01.01", 2456926],
|
35
|
-
["HY5776.01.01", 2457280],
|
36
|
-
["HY5777.01.01", 2457665],
|
37
|
-
["HY5778.01.01", 2458018],
|
38
|
-
["HY5779.01.01", 2458372],
|
39
|
-
["HY5780.01.01", 2458757],
|
40
|
-
["HY5781.01.01", 2459112],
|
41
|
-
["HY5782.01.01", 2459465],
|
42
|
-
["HY5783.01.01", 2459849],
|
43
|
-
["HY5784.01.01", 2460204],
|
44
|
-
["HY5785.01.01", 2460587],
|
45
|
-
["HY5786.01.01", 2460942],
|
46
|
-
["HY5787.01.01", 2461296],
|
47
|
-
["HY5788.01.01", 2461681],
|
48
|
-
["HY5789.01.01", 2462036],
|
49
|
-
["HY5790.01.01", 2462390],
|
50
|
-
["HY5791.01.01", 2462773],
|
51
|
-
["HY5792.01.01", 2463128]].each do |sample|
|
52
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
53
|
-
date += When.Duration('P1Y')
|
54
|
-
end
|
55
|
-
|
56
|
-
assert_equal("BCE3761(-3760).10.07",
|
57
|
-
(When.era('BCE')[0] ^ When.Calendar('Jewish').domain[''].first).to_s)
|
58
|
-
|
59
|
-
date = When.when?('4861-06-21^^Jewish')
|
60
|
-
assert_equal('4862-06*21', (date + When::P1Y).to_s)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
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 Jewish < MiniTest::TestCase
|
12
|
+
def test__jewish
|
13
|
+
date = When.when? 'HY5700.1.1'
|
14
|
+
[["HY5700.01.01", 2429521],
|
15
|
+
["HY5700.02.01", 2429551],
|
16
|
+
["HY5700.03.01", 2429581],
|
17
|
+
["HY5700.04.01", 2429611],
|
18
|
+
["HY5700.05.01", 2429640],
|
19
|
+
["HY5700.06*01", 2429670],
|
20
|
+
["HY5700.06=01", 2429700],
|
21
|
+
["HY5700.07.01", 2429729],
|
22
|
+
["HY5700.08.01", 2429759],
|
23
|
+
["HY5700.09.01", 2429788],
|
24
|
+
["HY5700.10.01", 2429818],
|
25
|
+
["HY5700.11.01", 2429847],
|
26
|
+
["HY5700.12.01", 2429877]].each do |sample|
|
27
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
28
|
+
date += When.Duration('P1M')
|
29
|
+
end
|
30
|
+
|
31
|
+
date = When.when? 'HY5773.1.1'
|
32
|
+
[["HY5773.01.01", 2456188],
|
33
|
+
["HY5774.01.01", 2456541],
|
34
|
+
["HY5775.01.01", 2456926],
|
35
|
+
["HY5776.01.01", 2457280],
|
36
|
+
["HY5777.01.01", 2457665],
|
37
|
+
["HY5778.01.01", 2458018],
|
38
|
+
["HY5779.01.01", 2458372],
|
39
|
+
["HY5780.01.01", 2458757],
|
40
|
+
["HY5781.01.01", 2459112],
|
41
|
+
["HY5782.01.01", 2459465],
|
42
|
+
["HY5783.01.01", 2459849],
|
43
|
+
["HY5784.01.01", 2460204],
|
44
|
+
["HY5785.01.01", 2460587],
|
45
|
+
["HY5786.01.01", 2460942],
|
46
|
+
["HY5787.01.01", 2461296],
|
47
|
+
["HY5788.01.01", 2461681],
|
48
|
+
["HY5789.01.01", 2462036],
|
49
|
+
["HY5790.01.01", 2462390],
|
50
|
+
["HY5791.01.01", 2462773],
|
51
|
+
["HY5792.01.01", 2463128]].each do |sample|
|
52
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
53
|
+
date += When.Duration('P1Y')
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_equal("BCE3761(-3760).10.07",
|
57
|
+
(When.era('BCE')[0] ^ When.Calendar('Jewish').domain[''].first).to_s)
|
58
|
+
|
59
|
+
date = When.when?('4861-06-21^^Jewish')
|
60
|
+
assert_equal('4862-06*21', (date + When::P1Y).to_s)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/test/test/region/shire.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
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 Shire < MiniTest::TestCase
|
12
|
-
def test_shire
|
13
|
-
date = When.when? '2001.1.1^^Shire?time_basis=+09:00'
|
14
|
-
[["2001-01-01", 2451901],
|
15
|
-
["2002-01-01", 2452266],
|
16
|
-
["2003-01-01", 2452632],
|
17
|
-
["2004-01-01", 2452997],
|
18
|
-
["2005-01-01", 2453362],
|
19
|
-
["2006-01-01", 2453727],
|
20
|
-
["2007-01-01", 2454093],
|
21
|
-
["2008-01-01", 2454458],
|
22
|
-
["2009-01-01", 2454823],
|
23
|
-
["2010-01-01", 2455188],
|
24
|
-
["2011-01-01", 2455554],
|
25
|
-
["2012-01-01", 2455919],
|
26
|
-
["2013-01-01", 2456284],
|
27
|
-
["2014-01-01", 2456649],
|
28
|
-
["2015-01-01", 2457015],
|
29
|
-
["2016-01-01", 2457380],
|
30
|
-
["2017-01-01", 2457745],
|
31
|
-
["2018-01-01", 2458110],
|
32
|
-
["2019-01-01", 2458476],
|
33
|
-
["2020-01-01", 2458841],
|
34
|
-
["2021-01-01", 2459206],
|
35
|
-
["2022-01-01", 2459571],
|
36
|
-
["2023-01-01", 2459936],
|
37
|
-
["2024-01-01", 2460302],
|
38
|
-
["2025-01-01", 2460667],
|
39
|
-
["2026-01-01", 2461032],
|
40
|
-
["2027-01-01", 2461397],
|
41
|
-
["2028-01-01", 2461763],
|
42
|
-
["2029-01-01", 2462128],
|
43
|
-
["2030-01-01", 2462493],
|
44
|
-
["2031-01-01", 2462858],
|
45
|
-
["2032-01-01", 2463224],
|
46
|
-
["2033-01-01", 2463589]].each do |sample|
|
47
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
48
|
-
date += When::P1Y
|
49
|
-
end
|
50
|
-
|
51
|
-
date = When.when? '2001.1.1'
|
52
|
-
400.times do
|
53
|
-
assert_equal([1,9], (When.Calendar('Shire') ^ date).cal_date[1..2])
|
54
|
-
date += When::P1Y
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
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 Shire < MiniTest::TestCase
|
12
|
+
def test_shire
|
13
|
+
date = When.when? '2001.1.1^^Shire?time_basis=+09:00'
|
14
|
+
[["2001-01-01", 2451901],
|
15
|
+
["2002-01-01", 2452266],
|
16
|
+
["2003-01-01", 2452632],
|
17
|
+
["2004-01-01", 2452997],
|
18
|
+
["2005-01-01", 2453362],
|
19
|
+
["2006-01-01", 2453727],
|
20
|
+
["2007-01-01", 2454093],
|
21
|
+
["2008-01-01", 2454458],
|
22
|
+
["2009-01-01", 2454823],
|
23
|
+
["2010-01-01", 2455188],
|
24
|
+
["2011-01-01", 2455554],
|
25
|
+
["2012-01-01", 2455919],
|
26
|
+
["2013-01-01", 2456284],
|
27
|
+
["2014-01-01", 2456649],
|
28
|
+
["2015-01-01", 2457015],
|
29
|
+
["2016-01-01", 2457380],
|
30
|
+
["2017-01-01", 2457745],
|
31
|
+
["2018-01-01", 2458110],
|
32
|
+
["2019-01-01", 2458476],
|
33
|
+
["2020-01-01", 2458841],
|
34
|
+
["2021-01-01", 2459206],
|
35
|
+
["2022-01-01", 2459571],
|
36
|
+
["2023-01-01", 2459936],
|
37
|
+
["2024-01-01", 2460302],
|
38
|
+
["2025-01-01", 2460667],
|
39
|
+
["2026-01-01", 2461032],
|
40
|
+
["2027-01-01", 2461397],
|
41
|
+
["2028-01-01", 2461763],
|
42
|
+
["2029-01-01", 2462128],
|
43
|
+
["2030-01-01", 2462493],
|
44
|
+
["2031-01-01", 2462858],
|
45
|
+
["2032-01-01", 2463224],
|
46
|
+
["2033-01-01", 2463589]].each do |sample|
|
47
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
48
|
+
date += When::P1Y
|
49
|
+
end
|
50
|
+
|
51
|
+
date = When.when? '2001.1.1'
|
52
|
+
400.times do
|
53
|
+
assert_equal([1,9], (When.Calendar('Shire') ^ date).cal_date[1..2])
|
54
|
+
date += When::P1Y
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/test/test/region/swedish.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
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 Swedish < MiniTest::TestCase
|
12
|
-
def test__swedish_date
|
13
|
-
|
14
|
-
dates = []
|
15
|
-
jdns = []
|
16
|
-
[2342042, 2346424].each do |base|
|
17
|
-
(-3..+3).each do |diff|
|
18
|
-
jdn = base + diff
|
19
|
-
jdate = When::Julian ^ jdn
|
20
|
-
s1date = When::Swedish ^ jdn
|
21
|
-
s2date = When.tm_pos(*(s1date.cal_date + [{:frame=>When::Swedish}]))
|
22
|
-
dates << s1date.to_s
|
23
|
-
jdns << [s1date.to_s == s2date.to_s, s1date.to_i == jdn, s2date.to_i == jdn].uniq
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
assert_equal(%w(1700-02-26 1700-02-27 1700-02-28 1700-03-01 1700-03-02 1700-03-03 1700-03-04
|
28
|
-
1712-02-26 1712-02-27 1712-02-28 1712-02-29 1712-02-30 1712-03-01 1712-03-02), dates)
|
29
|
-
assert_equal([[true]], jdns.uniq)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test__swedish_easter
|
33
|
-
|
34
|
-
dates = []
|
35
|
-
civil = When.Calendar('Civil?old=Swedish&reform_date=1753-03-01')
|
36
|
-
((1700..1711).to_a + (1740..1752).to_a+[1802,1805,1818]).each do |year|
|
37
|
-
dates << When.tm_pos(year, {:frame=>civil}).easter.to_s
|
38
|
-
end
|
39
|
-
assert_equal(%w(1700-04-01 1701-04-21 1702-04-06 1703-03-29 1704-04-17 1705-04-02 1706-03-25
|
40
|
-
1707-04-14 1708-04-05 1709-04-18 1710-04-10 1711-03-26 1740-04-06 1741-03-22
|
41
|
-
1742-03-14 1743-04-03 1744-03-18 1745-04-07 1746-03-30 1747-03-22 1748-04-03
|
42
|
-
1749-03-26 1750-03-18 1751-03-31 1752-03-22 1802-04-25 1805-04-21 1818-03-29), dates)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
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 Swedish < MiniTest::TestCase
|
12
|
+
def test__swedish_date
|
13
|
+
|
14
|
+
dates = []
|
15
|
+
jdns = []
|
16
|
+
[2342042, 2346424].each do |base|
|
17
|
+
(-3..+3).each do |diff|
|
18
|
+
jdn = base + diff
|
19
|
+
jdate = When::Julian ^ jdn
|
20
|
+
s1date = When::Swedish ^ jdn
|
21
|
+
s2date = When.tm_pos(*(s1date.cal_date + [{:frame=>When::Swedish}]))
|
22
|
+
dates << s1date.to_s
|
23
|
+
jdns << [s1date.to_s == s2date.to_s, s1date.to_i == jdn, s2date.to_i == jdn].uniq
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_equal(%w(1700-02-26 1700-02-27 1700-02-28 1700-03-01 1700-03-02 1700-03-03 1700-03-04
|
28
|
+
1712-02-26 1712-02-27 1712-02-28 1712-02-29 1712-02-30 1712-03-01 1712-03-02), dates)
|
29
|
+
assert_equal([[true]], jdns.uniq)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test__swedish_easter
|
33
|
+
|
34
|
+
dates = []
|
35
|
+
civil = When.Calendar('Civil?old=Swedish&reform_date=1753-03-01')
|
36
|
+
((1700..1711).to_a + (1740..1752).to_a+[1802,1805,1818]).each do |year|
|
37
|
+
dates << When.tm_pos(year, {:frame=>civil}).easter.to_s
|
38
|
+
end
|
39
|
+
assert_equal(%w(1700-04-01 1701-04-21 1702-04-06 1703-03-29 1704-04-17 1705-04-02 1706-03-25
|
40
|
+
1707-04-14 1708-04-05 1709-04-18 1710-04-10 1711-03-26 1740-04-06 1741-03-22
|
41
|
+
1742-03-14 1743-04-03 1744-03-18 1745-04-07 1746-03-30 1747-03-22 1748-04-03
|
42
|
+
1749-03-26 1750-03-18 1751-03-31 1752-03-22 1802-04-25 1805-04-21 1818-03-29), dates)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/test/region/thai.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011-2013 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 Thai < MiniTest::TestCase
|
12
|
-
def test_thai_date
|
13
|
-
|
14
|
-
date = When.Resource('_c:ThaiP') ^ When.when?('2011-05-16')
|
15
|
-
[["1373-07-15", 2455698],
|
16
|
-
["1373-07<01", 2455699],
|
17
|
-
["1373-07<02", 2455700]].each do |sample|
|
18
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
19
|
-
date += When.Duration('P1D')
|
20
|
-
end
|
21
|
-
|
22
|
-
[["1373-07<03", 2455701],
|
23
|
-
["1373-08-03", 2455716],
|
24
|
-
["1373-08<03", 2455731],
|
25
|
-
["1373-09-03", 2455745],
|
26
|
-
["1373-09<03", 2455760],
|
27
|
-
["1373-10-03", 2455775],
|
28
|
-
["1373-10<03", 2455790],
|
29
|
-
["1373-11-03", 2455804],
|
30
|
-
["1373-11<03", 2455819],
|
31
|
-
["1373-12-03", 2455834]].each do |sample|
|
32
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
33
|
-
date += When.Duration('P1M')
|
34
|
-
end
|
35
|
-
|
36
|
-
date = When.Resource('_c:Thai') ^ When.when?('2011-05-16')
|
37
|
-
[["1373-06-14", 2455698],
|
38
|
-
["1373-06-15", 2455699],
|
39
|
-
["1373-06<01", 2455700]].each do |sample|
|
40
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
41
|
-
date += When.Duration('P1D')
|
42
|
-
end
|
43
|
-
|
44
|
-
[["1373-06<02", 2455701],
|
45
|
-
["1373-07-02", 2455716],
|
46
|
-
["1373-07<02", 2455731],
|
47
|
-
["1373-08-02", 2455745],
|
48
|
-
["1373-08<02", 2455760],
|
49
|
-
["1373-09-02", 2455775],
|
50
|
-
["1373-09<02", 2455790],
|
51
|
-
["1373-10-02", 2455804],
|
52
|
-
["1373-10<02", 2455819],
|
53
|
-
["1373-11-02", 2455834],
|
54
|
-
["1373-11<02", 2455849],
|
55
|
-
["1373-12-02", 2455863],
|
56
|
-
["1373-12<02", 2455878],
|
57
|
-
["1374-01-02", 2455893],
|
58
|
-
["1374-01<02", 2455908],
|
59
|
-
["1374-02-02", 2455922],
|
60
|
-
["1374-02<02", 2455937],
|
61
|
-
["1374-03-02", 2455952],
|
62
|
-
["1374-03<02", 2455967],
|
63
|
-
["1374-04-02", 2455981],
|
64
|
-
["1374-04<02", 2455996],
|
65
|
-
["1374-05-02", 2456011],
|
66
|
-
["1374-05<02", 2456026],
|
67
|
-
["1374-06-02", 2456040],
|
68
|
-
["1374-06<02", 2456055],
|
69
|
-
["1374-07-02", 2456070],
|
70
|
-
["1374-07<02", 2456085],
|
71
|
-
["1374-08&02", 2456099],
|
72
|
-
["1374-08*02", 2456114],
|
73
|
-
["1374-08-02", 2456129],
|
74
|
-
["1374-08<02", 2456144],
|
75
|
-
["1374-09-02", 2456159],
|
76
|
-
["1374-09<02", 2456174],
|
77
|
-
["1374-10-02", 2456188],
|
78
|
-
["1374-10<02", 2456203],
|
79
|
-
["1374-11-02", 2456218],
|
80
|
-
["1374-11<02", 2456233],
|
81
|
-
["1374-12-02", 2456247],
|
82
|
-
["1374-12<02", 2456262],
|
83
|
-
["1375-01-02", 2456277]].each do |sample|
|
84
|
-
assert_equal(sample, [date.to_s, date.to_i])
|
85
|
-
date += When.Duration('P1M')
|
86
|
-
end
|
87
|
-
|
88
|
-
date = When.when?('1374-08&02', {:frame=>When.Resource('_c:Thai')})
|
89
|
-
assert_equal(["1374-08&02", 2456099, "adhika Āṣāḍha Śuklapakṣa"],
|
90
|
-
[date.to_s, date.to_i, date.name('Month').translate('en')])
|
91
|
-
|
92
|
-
diffs = [
|
93
|
-
[1840,-1], [1860, 1], [1865, 1], [1876,-1], [1880,-1], [1881,-1], [1891,29], [1901, 1],
|
94
|
-
[1902, 1], [1906, 1], [1910,30], [1911, 1], [1915, 1], [1916, 1], [1922, 1], [1926, 1],
|
95
|
-
[1927, 1], [1934, 1], [1935, 1], [1936, 1], [1963, 1], [2024,-1], [2025,-1], [2040,-1],
|
96
|
-
[2041,-1]]
|
97
|
-
(1840..2050).each do |year|
|
98
|
-
cdate = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiC').to_i
|
99
|
-
tdate = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT').to_i
|
100
|
-
unless cdate == tdate
|
101
|
-
assert_equal(diffs.shift, [year, tdate - cdate])
|
102
|
-
end
|
103
|
-
end
|
104
|
-
assert_equal(0, diffs.size)
|
105
|
-
|
106
|
-
diffs = [[1961,0], [1962,0], [1963,1], [1964,1]]
|
107
|
-
(1961..1964).each do |year|
|
108
|
-
t0date = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT').to_i
|
109
|
-
t1date = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT?patch=1962A').to_i
|
110
|
-
assert_equal(diffs.shift, [year, t0date - t1date])
|
111
|
-
end
|
112
|
-
assert_equal(0, diffs.size)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011-2013 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 Thai < MiniTest::TestCase
|
12
|
+
def test_thai_date
|
13
|
+
|
14
|
+
date = When.Resource('_c:ThaiP') ^ When.when?('2011-05-16')
|
15
|
+
[["1373-07-15", 2455698],
|
16
|
+
["1373-07<01", 2455699],
|
17
|
+
["1373-07<02", 2455700]].each do |sample|
|
18
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
19
|
+
date += When.Duration('P1D')
|
20
|
+
end
|
21
|
+
|
22
|
+
[["1373-07<03", 2455701],
|
23
|
+
["1373-08-03", 2455716],
|
24
|
+
["1373-08<03", 2455731],
|
25
|
+
["1373-09-03", 2455745],
|
26
|
+
["1373-09<03", 2455760],
|
27
|
+
["1373-10-03", 2455775],
|
28
|
+
["1373-10<03", 2455790],
|
29
|
+
["1373-11-03", 2455804],
|
30
|
+
["1373-11<03", 2455819],
|
31
|
+
["1373-12-03", 2455834]].each do |sample|
|
32
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
33
|
+
date += When.Duration('P1M')
|
34
|
+
end
|
35
|
+
|
36
|
+
date = When.Resource('_c:Thai') ^ When.when?('2011-05-16')
|
37
|
+
[["1373-06-14", 2455698],
|
38
|
+
["1373-06-15", 2455699],
|
39
|
+
["1373-06<01", 2455700]].each do |sample|
|
40
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
41
|
+
date += When.Duration('P1D')
|
42
|
+
end
|
43
|
+
|
44
|
+
[["1373-06<02", 2455701],
|
45
|
+
["1373-07-02", 2455716],
|
46
|
+
["1373-07<02", 2455731],
|
47
|
+
["1373-08-02", 2455745],
|
48
|
+
["1373-08<02", 2455760],
|
49
|
+
["1373-09-02", 2455775],
|
50
|
+
["1373-09<02", 2455790],
|
51
|
+
["1373-10-02", 2455804],
|
52
|
+
["1373-10<02", 2455819],
|
53
|
+
["1373-11-02", 2455834],
|
54
|
+
["1373-11<02", 2455849],
|
55
|
+
["1373-12-02", 2455863],
|
56
|
+
["1373-12<02", 2455878],
|
57
|
+
["1374-01-02", 2455893],
|
58
|
+
["1374-01<02", 2455908],
|
59
|
+
["1374-02-02", 2455922],
|
60
|
+
["1374-02<02", 2455937],
|
61
|
+
["1374-03-02", 2455952],
|
62
|
+
["1374-03<02", 2455967],
|
63
|
+
["1374-04-02", 2455981],
|
64
|
+
["1374-04<02", 2455996],
|
65
|
+
["1374-05-02", 2456011],
|
66
|
+
["1374-05<02", 2456026],
|
67
|
+
["1374-06-02", 2456040],
|
68
|
+
["1374-06<02", 2456055],
|
69
|
+
["1374-07-02", 2456070],
|
70
|
+
["1374-07<02", 2456085],
|
71
|
+
["1374-08&02", 2456099],
|
72
|
+
["1374-08*02", 2456114],
|
73
|
+
["1374-08-02", 2456129],
|
74
|
+
["1374-08<02", 2456144],
|
75
|
+
["1374-09-02", 2456159],
|
76
|
+
["1374-09<02", 2456174],
|
77
|
+
["1374-10-02", 2456188],
|
78
|
+
["1374-10<02", 2456203],
|
79
|
+
["1374-11-02", 2456218],
|
80
|
+
["1374-11<02", 2456233],
|
81
|
+
["1374-12-02", 2456247],
|
82
|
+
["1374-12<02", 2456262],
|
83
|
+
["1375-01-02", 2456277]].each do |sample|
|
84
|
+
assert_equal(sample, [date.to_s, date.to_i])
|
85
|
+
date += When.Duration('P1M')
|
86
|
+
end
|
87
|
+
|
88
|
+
date = When.when?('1374-08&02', {:frame=>When.Resource('_c:Thai')})
|
89
|
+
assert_equal(["1374-08&02", 2456099, "adhika Āṣāḍha Śuklapakṣa"],
|
90
|
+
[date.to_s, date.to_i, date.name('Month').translate('en')])
|
91
|
+
|
92
|
+
diffs = [
|
93
|
+
[1840,-1], [1860, 1], [1865, 1], [1876,-1], [1880,-1], [1881,-1], [1891,29], [1901, 1],
|
94
|
+
[1902, 1], [1906, 1], [1910,30], [1911, 1], [1915, 1], [1916, 1], [1922, 1], [1926, 1],
|
95
|
+
[1927, 1], [1934, 1], [1935, 1], [1936, 1], [1963, 1], [2024,-1], [2025,-1], [2040,-1],
|
96
|
+
[2041,-1]]
|
97
|
+
(1840..2050).each do |year|
|
98
|
+
cdate = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiC').to_i
|
99
|
+
tdate = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT').to_i
|
100
|
+
unless cdate == tdate
|
101
|
+
assert_equal(diffs.shift, [year, tdate - cdate])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
assert_equal(0, diffs.size)
|
105
|
+
|
106
|
+
diffs = [[1961,0], [1962,0], [1963,1], [1964,1]]
|
107
|
+
(1961..1964).each do |year|
|
108
|
+
t0date = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT').to_i
|
109
|
+
t1date = When.TemporalPosition(year-638, 1, 1, :frame=>'ThaiT?patch=1962A').to_i
|
110
|
+
assert_equal(diffs.shift, [year, t0date - t1date])
|
111
|
+
end
|
112
|
+
assert_equal(0, diffs.size)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|