when_exe 0.4.2 → 0.4.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -23
  3. data/lib/when_exe/ephemeris/moon.rb +333 -333
  4. data/lib/when_exe/linkeddata.rb +0 -1
  5. data/lib/when_exe/locales/encoding_conversion.rb +134 -134
  6. data/lib/when_exe/locales/iast.rb +90 -90
  7. data/lib/when_exe/locales/transliteration_table.rb +62 -62
  8. data/lib/when_exe/parts/method_cash.rb +224 -224
  9. data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
  10. data/lib/when_exe/region/geologicalage.rb +1 -1
  11. data/lib/when_exe/region/japanese/calendars.rb +397 -397
  12. data/lib/when_exe/region/japanese/eclipses.rb +1194 -1194
  13. data/lib/when_exe/region/japanese/nihon_shoki.rb +70 -70
  14. data/lib/when_exe/region/korean.rb +384 -384
  15. data/lib/when_exe/region/ryukyu.rb +101 -101
  16. data/lib/when_exe/tmposition.rb +2 -2
  17. data/lib/when_exe/tmreference.rb +3 -3
  18. data/lib/when_exe/version.rb +1 -1
  19. data/test/scripts/geometric_complex.rb +41 -41
  20. data/test/scripts/korea.rb +59 -59
  21. data/test/scripts/thai.rb +36 -36
  22. data/test/test/basictypes.rb +431 -431
  23. data/test/test/calendarnote.rb +86 -86
  24. data/test/test/calendartypes.rb +97 -97
  25. data/test/test/coordinates.rb +397 -397
  26. data/test/test/ephemeris.rb +115 -115
  27. data/test/test/ephemeris/moon.rb +14 -14
  28. data/test/test/ephemeris/planets.rb +14 -14
  29. data/test/test/ephemeris/sun.rb +14 -14
  30. data/test/test/inspect.rb +153 -153
  31. data/test/test/parts.rb +488 -488
  32. data/test/test/region/armenian.rb +20 -20
  33. data/test/test/region/bahai.rb +58 -58
  34. data/test/test/region/balinese.rb +34 -34
  35. data/test/test/region/chinese.rb +229 -229
  36. data/test/test/region/christian.rb +226 -226
  37. data/test/test/region/coptic.rb +27 -27
  38. data/test/test/region/discordian.rb +20 -20
  39. data/test/test/region/french.rb +33 -33
  40. data/test/test/region/geologicalage.rb +17 -17
  41. data/test/test/region/iran.rb +54 -54
  42. data/test/test/region/islamic.rb +54 -54
  43. data/test/test/region/japanese.rb +261 -261
  44. data/test/test/region/jewish.rb +63 -63
  45. data/test/test/region/shire.rb +58 -58
  46. data/test/test/region/swedish.rb +45 -45
  47. data/test/test/region/thai.rb +116 -116
  48. data/test/test/region/tibetan.rb +30 -30
  49. data/test/test/region/vietnamese.rb +102 -102
  50. data/test/test/region/zoroastrian.rb +58 -58
  51. data/test/test/timestandard.rb +81 -81
  52. data/test/test/tmobjects.rb +402 -402
  53. data/test/test/tmreference.rb +157 -157
  54. metadata +4 -88
@@ -1,20 +1,20 @@
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 Armenian < MiniTest::TestCase
12
- def test__armenian
13
- date = When.when?('1-1-1^^Armenian')
14
- assert_equal(["0001-01-01", "0552-07-11"], [date.to_s, (When::Julian ^ date).to_s])
15
-
16
- date = When.when?('1462-1-1^^Armenian')
17
- assert_equal(["1462-01-01", "2012-07-24"], [date.to_s, (When::Gregorian ^ date).to_s])
18
- end
19
- end
20
- 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 Armenian < MiniTest::TestCase
12
+ def test__armenian
13
+ date = When.when?('1-1-1^^Armenian')
14
+ assert_equal(["0001-01-01", "0552-07-11"], [date.to_s, (When::Julian ^ date).to_s])
15
+
16
+ date = When.when?('1462-1-1^^Armenian')
17
+ assert_equal(["1462-01-01", "2012-07-24"], [date.to_s, (When::Gregorian ^ date).to_s])
18
+ end
19
+ end
20
+ end
@@ -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 Bahai < MiniTest::TestCase
12
- def test_bahai
13
- date = When.when? '1.9.1.1.1^^Bahai?location=(_co:Iranian::Tehran)'
14
- [["01.09.01.01.01", "1996-03-20", 2450163],
15
- ["01.09.02.01.01", "1997-03-20", 2450528],
16
- ["01.09.03.01.01", "1998-03-21", 2450894],
17
- ["01.09.04.01.01", "1999-03-21", 2451259],
18
- ["01.09.05.01.01", "2000-03-20", 2451624],
19
- ["01.09.06.01.01", "2001-03-20", 2451989],
20
- ["01.09.07.01.01", "2002-03-21", 2452355],
21
- ["01.09.08.01.01", "2003-03-21", 2452720],
22
- ["01.09.09.01.01", "2004-03-20", 2453085],
23
- ["01.09.10.01.01", "2005-03-20", 2453450],
24
- ["01.09.11.01.01", "2006-03-21", 2453816],
25
- ["01.09.12.01.01", "2007-03-21", 2454181],
26
- ["01.09.13.01.01", "2008-03-20", 2454546],
27
- ["01.09.14.01.01", "2009-03-20", 2454911],
28
- ["01.09.15.01.01", "2010-03-21", 2455277],
29
- ["01.09.16.01.01", "2011-03-21", 2455642],
30
- ["01.09.17.01.01", "2012-03-20", 2456007],
31
- ["01.09.18.01.01", "2013-03-20", 2456372],
32
- ["01.09.19.01.01", "2014-03-21", 2456738],
33
- ["01.10.01.01.01", "2015-03-21", 2457103],
34
- ["01.10.02.01.01", "2016-03-20", 2457468],
35
- ["01.10.03.01.01", "2017-03-20", 2457833],
36
- ["01.10.04.01.01", "2018-03-21", 2458199],
37
- ["01.10.05.01.01", "2019-03-21", 2458564],
38
- ["01.10.06.01.01", "2020-03-20", 2458929],
39
- ["01.10.07.01.01", "2021-03-20", 2459294],
40
- ["01.10.08.01.01", "2022-03-21", 2459660],
41
- ["01.10.09.01.01", "2023-03-21", 2460025],
42
- ["01.10.10.01.01", "2024-03-20", 2460390],
43
- ["01.10.11.01.01", "2025-03-20", 2460755],
44
- ["01.10.12.01.01", "2026-03-20", 2461120],
45
- ["01.10.13.01.01", "2027-03-21", 2461486],
46
- ["01.10.14.01.01", "2028-03-20", 2461851]].each do |sample|
47
- assert_equal(sample, [date.to_s, (When::Gregorian ^ date).to_s, date.to_i])
48
- date += When::P1Y
49
- end
50
-
51
- date = When.when? '2001.3.21'
52
- 400.times do
53
- assert_equal([1,1], (When.Calendar('Bahai') ^ date).cal_date[-2..-1])
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 Bahai < MiniTest::TestCase
12
+ def test_bahai
13
+ date = When.when? '1.9.1.1.1^^Bahai?location=(_co:Iranian::Tehran)'
14
+ [["01.09.01.01.01", "1996-03-20", 2450163],
15
+ ["01.09.02.01.01", "1997-03-20", 2450528],
16
+ ["01.09.03.01.01", "1998-03-21", 2450894],
17
+ ["01.09.04.01.01", "1999-03-21", 2451259],
18
+ ["01.09.05.01.01", "2000-03-20", 2451624],
19
+ ["01.09.06.01.01", "2001-03-20", 2451989],
20
+ ["01.09.07.01.01", "2002-03-21", 2452355],
21
+ ["01.09.08.01.01", "2003-03-21", 2452720],
22
+ ["01.09.09.01.01", "2004-03-20", 2453085],
23
+ ["01.09.10.01.01", "2005-03-20", 2453450],
24
+ ["01.09.11.01.01", "2006-03-21", 2453816],
25
+ ["01.09.12.01.01", "2007-03-21", 2454181],
26
+ ["01.09.13.01.01", "2008-03-20", 2454546],
27
+ ["01.09.14.01.01", "2009-03-20", 2454911],
28
+ ["01.09.15.01.01", "2010-03-21", 2455277],
29
+ ["01.09.16.01.01", "2011-03-21", 2455642],
30
+ ["01.09.17.01.01", "2012-03-20", 2456007],
31
+ ["01.09.18.01.01", "2013-03-20", 2456372],
32
+ ["01.09.19.01.01", "2014-03-21", 2456738],
33
+ ["01.10.01.01.01", "2015-03-21", 2457103],
34
+ ["01.10.02.01.01", "2016-03-20", 2457468],
35
+ ["01.10.03.01.01", "2017-03-20", 2457833],
36
+ ["01.10.04.01.01", "2018-03-21", 2458199],
37
+ ["01.10.05.01.01", "2019-03-21", 2458564],
38
+ ["01.10.06.01.01", "2020-03-20", 2458929],
39
+ ["01.10.07.01.01", "2021-03-20", 2459294],
40
+ ["01.10.08.01.01", "2022-03-21", 2459660],
41
+ ["01.10.09.01.01", "2023-03-21", 2460025],
42
+ ["01.10.10.01.01", "2024-03-20", 2460390],
43
+ ["01.10.11.01.01", "2025-03-20", 2460755],
44
+ ["01.10.12.01.01", "2026-03-20", 2461120],
45
+ ["01.10.13.01.01", "2027-03-21", 2461486],
46
+ ["01.10.14.01.01", "2028-03-20", 2461851]].each do |sample|
47
+ assert_equal(sample, [date.to_s, (When::Gregorian ^ date).to_s, date.to_i])
48
+ date += When::P1Y
49
+ end
50
+
51
+ date = When.when? '2001.3.21'
52
+ 400.times do
53
+ assert_equal([1,1], (When.Calendar('Bahai') ^ date).cal_date[-2..-1])
54
+ date += When::P1Y
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,34 +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
-
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
+
@@ -1,229 +1,229 @@
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_table
13
- assert_equal({1677=>{"iJ"=>"Ij"},
14
- 1698=>{"jK"=>"Jk"},
15
- 1709=>{"aB"=>"Ab", "jK"=>"Jk"},
16
- 1727=>{"cC"=>"Cc"},
17
- 1730=>{"Cd"=>"cD"},
18
- 1751=>{"Jk"=>"jK"},
19
- 1778=>{"Cd"=>"cD"},
20
- 1841=>{"kL"=>"Kl"}}, When.Calendar('Korean').verify(When.Calendar('Chinese1645'), 1654..1911))
21
- end
22
-
23
- def test_chinese_date
24
-
25
- emd = When.Resource('_c:EphemerisBasedSolar?time_basis=+09:00')
26
- date = When.when?('2009-01-01', {:frame=>emd})
27
- [
28
- ["2009-01-01", 2454867],
29
- ["2009-02-01", 2454896],
30
- ["2009-03-01", 2454927],
31
- ["2009-04-01", 2454957],
32
- ["2009-05-01", 2454988],
33
- ["2009-06-01", 2455020],
34
- ["2009-07-01", 2455051],
35
- ["2009-08-01", 2455082],
36
- ["2009-09-01", 2455113],
37
- ["2009-10-01", 2455143],
38
- ["2009-11-01", 2455173],
39
- ["2009-12-01", 2455202]
40
- ].each do |sample|
41
- assert_equal(sample, [date.to_s, date.to_i])
42
- date += When.Duration('P1M')
43
- end
44
-
45
- cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00'})
46
- date = When.when?('2009-01-01', {:frame=>cc})
47
- [
48
- ["2009-01-01", 2454858],
49
- ["2009-02-01", 2454888],
50
- ["2009-03-01", 2454918],
51
- ["2009-04-01", 2454947],
52
- ["2009-05-01", 2454976],
53
- ["2009-05=01", 2455006],
54
- ["2009-06-01", 2455035],
55
- ["2009-07-01", 2455064],
56
- ["2009-08-01", 2455094],
57
- ["2009-09-01", 2455123],
58
- ["2009-10-01", 2455153],
59
- ["2009-11-01", 2455182],
60
- ["2009-12-01", 2455212]
61
- ].each do |sample|
62
- assert_equal(sample, [date.to_s, date.to_i])
63
- date += When.Duration('P1M')
64
- end
65
-
66
- date = When.when?('2032-11-01', {:frame=>cc})
67
- [
68
- ["2032-11-01", 2463570],
69
- ["2032-12-01", 2463599],
70
- ["2033-01-01", 2463629],
71
- ["2033-02-01", 2463658],
72
- ["2033-03-01", 2463688],
73
- ["2033-04-01", 2463717],
74
- ["2033-05-01", 2463746],
75
- ["2033-06-01", 2463776],
76
- ["2033-07-01", 2463805],
77
- ["2033-08-01", 2463835],
78
- ["2033-09-01", 2463864],
79
- ["2033-10-01", 2463894],
80
- ["2033-11-01", 2463924],
81
- ["2033-11=01", 2463954],
82
- ["2033-12-01", 2463983],
83
- ["2034-01-01", 2464013],
84
- ["2034-02-01", 2464042],
85
- ["2034-03-01", 2464072]
86
- ].each do |sample|
87
- assert_equal(sample, [date.to_s, date.to_i])
88
- date += When.Duration('P1M')
89
- end
90
-
91
- date = When.when?('2728-11-01', {:frame=>cc})
92
- [
93
- ["2728-11-01", 2717768],
94
- ["2728-11=01", 2717798],
95
- ["2728-12-01", 2717827],
96
- ["2729-01-01", 2717857],
97
- ["2729-02-01", 2717887],
98
- ["2729-03-01", 2717916],
99
- ["2729-04-01", 2717946]
100
- ].each do |sample|
101
- assert_equal(sample, [date.to_s, date.to_i])
102
- date += When.Duration('P1M')
103
- end
104
-
105
- cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00', 'intercalary_span'=>3})
106
- date = When.when?('2728-11-01', {:frame=>cc})
107
- [
108
- ["2728-11-01", 2717768],
109
- ["2728-12-01", 2717798],
110
- ["2729-01-01", 2717827],
111
- ["2729-02-01", 2717857],
112
- ["2729-02=01", 2717887],
113
- ["2729-03-01", 2717916],
114
- ["2729-04-01", 2717946]
115
- ].each do |sample|
116
- assert_equal(sample, [date.to_s, date.to_i])
117
- date += When.Duration('P1M')
118
- end
119
- end
120
-
121
- def test_chinese_epoch
122
- date = When.when?('天保2.10.01')
123
- assert_equal([2390126, "天保02(1831).10.01", "神無月"],
124
- [date.to_i, date.to_s, date.name('Month')/'alias'])
125
- assert_equal("1831-11-04", (When.Calendar('Gregorian') ^ When.when?('天保02.10.01')).to_s)
126
-
127
- #=begin
128
- date = When.when?('天保2.10.01', {:count=>2})
129
- assert_equal([1926999, "天保02(0563).10.01", "十月"],
130
- [date.to_i, date.to_s, date.name('Month')])
131
-
132
- date = When.when?('天保3(564).10.01')
133
- assert_equal([1927353, "天保03(0564).10.01", "十月"],
134
- [date.to_i, date.to_s, date.name('Month')])
135
-
136
- date = When.when?('天保3.10.01', {'period'=>/梁/})
137
- assert_equal([1927353, "天保03(0564).10.01", "十月"],
138
- [date.to_i, date.to_s, date.name('Month')])
139
-
140
- assert_equal(["江戸時代", "後梁", "北斉"],
141
- When::era('天保').map {|v| v.parent.label}) # v.iri
142
-
143
- assert_raises(ArgumentError) { When.when?('天保3(0563).10.01') }
144
-
145
- date = When.when?('始皇帝26*10.01')
146
- assert_equal([1640641, 1640641, "<始皇帝>26(-220)*10.01", "十月"],
147
- [date.to_i, date.floor(When::YEAR).to_i, date.to_s, date.name('Month')])
148
-
149
- cc_221 = When.Resource('_c:Chinese_221')
150
- [
151
- ["-220*10-01", 1640641, "-00220*10-01", "十月"],
152
- ["-220*11-01", 1640671, "-00220*11-01", "十一月"],
153
- ["-220*12-01", 1640700, "-00220*12-01", "十二月"],
154
- ["-220-01-01", 1640730, "-00220-01-01", "正月"],
155
- ["-220-02-01", 1640759, "-00220-02-01", "二月"],
156
- ["-220-03-01", 1640789, "-00220-03-01", "三月"],
157
- ["-220-04-01", 1640818, "-00220-04-01", "四月"],
158
- ["-220-05-01", 1640848, "-00220-05-01", "五月"],
159
- ["-220-06-01", 1640877, "-00220-06-01", "六月"],
160
- ["-220-07-01", 1640907, "-00220-07-01", "七月"],
161
- ["-220-08-01", 1640937, "-00220-08-01", "八月"],
162
- ["-220-09-01", 1640966, "-00220-09-01", "九月"],
163
- ["-220-09=01", 1640996, "-00220-09=01", "閏九月"]
164
- ].each do |sample|
165
- date = When.when?(sample[0], {:frame=>cc_221})
166
- assert_equal(sample[1..-1],
167
- [date.to_i, date.to_s, date.name('Month')])
168
- end
169
- #=end
170
- end
171
-
172
- def test_daien_lunation
173
- sample = [
174
- 2938, 2993, 2708, 2760, 2573, 2691, 2622,
175
- 2626, 2637, 2523, 2551, 2637, 2625, 2886,
176
- 2703, 2764, 2791, 2680, 2792, 2764, 2797,
177
- 1402, 2626, 2380, 2807, 3003, 23, 2698]
178
-
179
- %w(0765-02-01 0765-12-01 0768-09-01 0769-04-01 0769-07-01 0771-05-01 0772-04-01
180
- 0772-09-01 0774-06-01 0775-02-01 0776-03-01 0780-05-01 0781-09-01 0784-10=01
181
- 0786-03-01 0788-04-01 0791-02-01 0791-09-01 0792-05-01 0813-12-01 0816-03-01
182
- 0820-02-01 0820-03-01 0822-02-01 0835-04-01 0836-04-01 0841-11-01 0853-02-01).each do |ptn|
183
- date = When.when?(ptn+ '^^ChineseTwin::大衍暦')
184
- formula = date.frame.formula[-1]
185
- m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
186
- t = formula.cn_to_time(m[0]) + Rational(1,2)
187
- assert_equal(sample.shift, (t - t.floor) * formula.denominator)
188
- end
189
- end
190
-
191
- def test_solar_terms_for_chinese_true_lunation
192
- date = When.when?('1690-1-1^^JapaneseTwin::貞享暦(節月)')
193
- formula = date.frame.formula[0]
194
- class << formula
195
- attr_reader :day_shift, :longitude_shift, :year_delta
196
- end
197
- assert_equal(["12S", Rational(-1,4), 2336118.19, 1.0e-06, 1684.0, 365.241696],
198
- [formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_delta, formula.year_epoch, formula.year_length.to_f])
199
- m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
200
- t = formula.cn_to_time(m[0]) + Rational(1,2)
201
- # assert_equal(["1690-01-01", 2338355, 20278, [15.923047, 30.436807, 2338340.576953]],
202
- # [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
203
-
204
- date = When.when?('1801-1-1^^JapaneseTwin::寛政暦(節月)')
205
- formula = date.frame.formula[0]
206
- class << formula
207
- attr_reader :day_epoch, :day_shift, :year_delta, :year_epoch, :year_length, :longitude_shift
208
- end
209
- assert_equal(["12S", Rational(-1,4), 2377390.607112, 1797.0, 365.242347071],
210
- [formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_epoch, formula.year_length.to_f])
211
- m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
212
- t = formula.cn_to_time(m[0]) + Rational(1,2)
213
- # assert_equal(["1801-01-01", 2378897, 21610, [15.986637, 30.436862, 2378882.513363]],
214
- # [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
215
- end
216
-
217
- def test_chinese_era
218
- assert_equal("慶元03(1197).01.10", When.when?('慶元3.1.10').to_s) # , {'period'=>/清/})
219
- assert_equal("紹熙03(1192).01.10", When.when?('紹煕3.1.10').to_s) # , {'period'=>/清/})
220
- assert_equal("康熙03(1664).01.10", When.when?('康煕3.1.10').to_s) # , {'period'=>/清/})
221
- assert_equal("紹熙03(1192).01.10", When.when?('紹熙3.1.10').to_s) # , {'period'=>/清/})
222
- assert_equal("崇徳03(1638).01.30", When.when?('崇徳3.1.30', {'period'=>/清/}).to_s)
223
- assert_raises(ArgumentError) {When.when?('崇徳3.1.30', {'period'=>/後金/})}
224
- assert_equal("正徳16(1521).03.14", When.TemporalPosition("正徳", 16, 3, 14, {"period"=>/明/}).to_s)
225
- assert_equal("正徳16(1521).03.14", When.when?('正徳16.3.14', {'period'=>/明/}).to_s)
226
- assert_equal("中国::明::崇禎11(1638).01.30",When.when?('崇禎11.1.30', {'period'=>/明/}).to_s)
227
- end
228
- end
229
- 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 Chinese < MiniTest::TestCase
12
+ def test_chinese_table
13
+ assert_equal({1677=>{"iJ"=>"Ij"},
14
+ 1698=>{"jK"=>"Jk"},
15
+ 1709=>{"aB"=>"Ab", "jK"=>"Jk"},
16
+ 1727=>{"cC"=>"Cc"},
17
+ 1730=>{"Cd"=>"cD"},
18
+ 1751=>{"Jk"=>"jK"},
19
+ 1778=>{"Cd"=>"cD"},
20
+ 1841=>{"kL"=>"Kl"}}, When.Calendar('Korean').verify(When.Calendar('Chinese1645'), 1654..1911))
21
+ end
22
+
23
+ def test_chinese_date
24
+
25
+ emd = When.Resource('_c:EphemerisBasedSolar?time_basis=+09:00')
26
+ date = When.when?('2009-01-01', {:frame=>emd})
27
+ [
28
+ ["2009-01-01", 2454867],
29
+ ["2009-02-01", 2454896],
30
+ ["2009-03-01", 2454927],
31
+ ["2009-04-01", 2454957],
32
+ ["2009-05-01", 2454988],
33
+ ["2009-06-01", 2455020],
34
+ ["2009-07-01", 2455051],
35
+ ["2009-08-01", 2455082],
36
+ ["2009-09-01", 2455113],
37
+ ["2009-10-01", 2455143],
38
+ ["2009-11-01", 2455173],
39
+ ["2009-12-01", 2455202]
40
+ ].each do |sample|
41
+ assert_equal(sample, [date.to_s, date.to_i])
42
+ date += When.Duration('P1M')
43
+ end
44
+
45
+ cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00'})
46
+ date = When.when?('2009-01-01', {:frame=>cc})
47
+ [
48
+ ["2009-01-01", 2454858],
49
+ ["2009-02-01", 2454888],
50
+ ["2009-03-01", 2454918],
51
+ ["2009-04-01", 2454947],
52
+ ["2009-05-01", 2454976],
53
+ ["2009-05=01", 2455006],
54
+ ["2009-06-01", 2455035],
55
+ ["2009-07-01", 2455064],
56
+ ["2009-08-01", 2455094],
57
+ ["2009-09-01", 2455123],
58
+ ["2009-10-01", 2455153],
59
+ ["2009-11-01", 2455182],
60
+ ["2009-12-01", 2455212]
61
+ ].each do |sample|
62
+ assert_equal(sample, [date.to_s, date.to_i])
63
+ date += When.Duration('P1M')
64
+ end
65
+
66
+ date = When.when?('2032-11-01', {:frame=>cc})
67
+ [
68
+ ["2032-11-01", 2463570],
69
+ ["2032-12-01", 2463599],
70
+ ["2033-01-01", 2463629],
71
+ ["2033-02-01", 2463658],
72
+ ["2033-03-01", 2463688],
73
+ ["2033-04-01", 2463717],
74
+ ["2033-05-01", 2463746],
75
+ ["2033-06-01", 2463776],
76
+ ["2033-07-01", 2463805],
77
+ ["2033-08-01", 2463835],
78
+ ["2033-09-01", 2463864],
79
+ ["2033-10-01", 2463894],
80
+ ["2033-11-01", 2463924],
81
+ ["2033-11=01", 2463954],
82
+ ["2033-12-01", 2463983],
83
+ ["2034-01-01", 2464013],
84
+ ["2034-02-01", 2464042],
85
+ ["2034-03-01", 2464072]
86
+ ].each do |sample|
87
+ assert_equal(sample, [date.to_s, date.to_i])
88
+ date += When.Duration('P1M')
89
+ end
90
+
91
+ date = When.when?('2728-11-01', {:frame=>cc})
92
+ [
93
+ ["2728-11-01", 2717768],
94
+ ["2728-11=01", 2717798],
95
+ ["2728-12-01", 2717827],
96
+ ["2729-01-01", 2717857],
97
+ ["2729-02-01", 2717887],
98
+ ["2729-03-01", 2717916],
99
+ ["2729-04-01", 2717946]
100
+ ].each do |sample|
101
+ assert_equal(sample, [date.to_s, date.to_i])
102
+ date += When.Duration('P1M')
103
+ end
104
+
105
+ cc = When::CalendarTypes::ChineseLuniSolar.new({'time_basis'=>'+09:00', 'intercalary_span'=>3})
106
+ date = When.when?('2728-11-01', {:frame=>cc})
107
+ [
108
+ ["2728-11-01", 2717768],
109
+ ["2728-12-01", 2717798],
110
+ ["2729-01-01", 2717827],
111
+ ["2729-02-01", 2717857],
112
+ ["2729-02=01", 2717887],
113
+ ["2729-03-01", 2717916],
114
+ ["2729-04-01", 2717946]
115
+ ].each do |sample|
116
+ assert_equal(sample, [date.to_s, date.to_i])
117
+ date += When.Duration('P1M')
118
+ end
119
+ end
120
+
121
+ def test_chinese_epoch
122
+ date = When.when?('天保2.10.01')
123
+ assert_equal([2390126, "天保02(1831).10.01", "神無月"],
124
+ [date.to_i, date.to_s, date.name('Month')/'alias'])
125
+ assert_equal("1831-11-04", (When.Calendar('Gregorian') ^ When.when?('天保02.10.01')).to_s)
126
+
127
+ #=begin
128
+ date = When.when?('天保2.10.01', {:count=>2})
129
+ assert_equal([1926999, "天保02(0563).10.01", "十月"],
130
+ [date.to_i, date.to_s, date.name('Month')])
131
+
132
+ date = When.when?('天保3(564).10.01')
133
+ assert_equal([1927353, "天保03(0564).10.01", "十月"],
134
+ [date.to_i, date.to_s, date.name('Month')])
135
+
136
+ date = When.when?('天保3.10.01', {'period'=>/梁/})
137
+ assert_equal([1927353, "天保03(0564).10.01", "十月"],
138
+ [date.to_i, date.to_s, date.name('Month')])
139
+
140
+ assert_equal(["江戸時代", "後梁", "北斉"],
141
+ When::era('天保').map {|v| v.parent.label}) # v.iri
142
+
143
+ assert_raises(ArgumentError) { When.when?('天保3(0563).10.01') }
144
+
145
+ date = When.when?('始皇帝26*10.01')
146
+ assert_equal([1640641, 1640641, "<始皇帝>26(-220)*10.01", "十月"],
147
+ [date.to_i, date.floor(When::YEAR).to_i, date.to_s, date.name('Month')])
148
+
149
+ cc_221 = When.Resource('_c:Chinese_221')
150
+ [
151
+ ["-220*10-01", 1640641, "-00220*10-01", "十月"],
152
+ ["-220*11-01", 1640671, "-00220*11-01", "十一月"],
153
+ ["-220*12-01", 1640700, "-00220*12-01", "十二月"],
154
+ ["-220-01-01", 1640730, "-00220-01-01", "正月"],
155
+ ["-220-02-01", 1640759, "-00220-02-01", "二月"],
156
+ ["-220-03-01", 1640789, "-00220-03-01", "三月"],
157
+ ["-220-04-01", 1640818, "-00220-04-01", "四月"],
158
+ ["-220-05-01", 1640848, "-00220-05-01", "五月"],
159
+ ["-220-06-01", 1640877, "-00220-06-01", "六月"],
160
+ ["-220-07-01", 1640907, "-00220-07-01", "七月"],
161
+ ["-220-08-01", 1640937, "-00220-08-01", "八月"],
162
+ ["-220-09-01", 1640966, "-00220-09-01", "九月"],
163
+ ["-220-09=01", 1640996, "-00220-09=01", "閏九月"]
164
+ ].each do |sample|
165
+ date = When.when?(sample[0], {:frame=>cc_221})
166
+ assert_equal(sample[1..-1],
167
+ [date.to_i, date.to_s, date.name('Month')])
168
+ end
169
+ #=end
170
+ end
171
+
172
+ def test_daien_lunation
173
+ sample = [
174
+ 2938, 2993, 2708, 2760, 2573, 2691, 2622,
175
+ 2626, 2637, 2523, 2551, 2637, 2625, 2886,
176
+ 2703, 2764, 2791, 2680, 2792, 2764, 2797,
177
+ 1402, 2626, 2380, 2807, 3003, 23, 2698]
178
+
179
+ %w(0765-02-01 0765-12-01 0768-09-01 0769-04-01 0769-07-01 0771-05-01 0772-04-01
180
+ 0772-09-01 0774-06-01 0775-02-01 0776-03-01 0780-05-01 0781-09-01 0784-10=01
181
+ 0786-03-01 0788-04-01 0791-02-01 0791-09-01 0792-05-01 0813-12-01 0816-03-01
182
+ 0820-02-01 0820-03-01 0822-02-01 0835-04-01 0836-04-01 0841-11-01 0853-02-01).each do |ptn|
183
+ date = When.when?(ptn+ '^^ChineseTwin::大衍暦')
184
+ formula = date.frame.formula[-1]
185
+ m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
186
+ t = formula.cn_to_time(m[0]) + Rational(1,2)
187
+ assert_equal(sample.shift, (t - t.floor) * formula.denominator)
188
+ end
189
+ end
190
+
191
+ def test_solar_terms_for_chinese_true_lunation
192
+ date = When.when?('1690-1-1^^JapaneseTwin::貞享暦(節月)')
193
+ formula = date.frame.formula[0]
194
+ class << formula
195
+ attr_reader :day_shift, :longitude_shift, :year_delta
196
+ end
197
+ assert_equal(["12S", Rational(-1,4), 2336118.19, 1.0e-06, 1684.0, 365.241696],
198
+ [formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_delta, formula.year_epoch, formula.year_length.to_f])
199
+ m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
200
+ t = formula.cn_to_time(m[0]) + Rational(1,2)
201
+ # assert_equal(["1690-01-01", 2338355, 20278, [15.923047, 30.436807, 2338340.576953]],
202
+ # [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
203
+
204
+ date = When.when?('1801-1-1^^JapaneseTwin::寛政暦(節月)')
205
+ formula = date.frame.formula[0]
206
+ class << formula
207
+ attr_reader :day_epoch, :day_shift, :year_delta, :year_epoch, :year_length, :longitude_shift
208
+ end
209
+ assert_equal(["12S", Rational(-1,4), 2377390.607112, 1797.0, 365.242347071],
210
+ [formula.formula, formula.longitude_shift, formula.day_epoch, formula.year_epoch, formula.year_length.to_f])
211
+ m = When::Coordinates::Residue.mod(date.to_i+1) {|cn| formula.cn_to_time(cn)}
212
+ t = formula.cn_to_time(m[0]) + Rational(1,2)
213
+ # assert_equal(["1801-01-01", 2378897, 21610, [15.986637, 30.436862, 2378882.513363]],
214
+ # [date.to_s, date.to_i, m[0], [m[1], m[2], t].map {|x| (x*1000000).round / 1000000.0}])
215
+ end
216
+
217
+ def test_chinese_era
218
+ assert_equal("慶元03(1197).01.10", When.when?('慶元3.1.10').to_s) # , {'period'=>/清/})
219
+ assert_equal("紹熙03(1192).01.10", When.when?('紹煕3.1.10').to_s) # , {'period'=>/清/})
220
+ assert_equal("康熙03(1664).01.10", When.when?('康煕3.1.10').to_s) # , {'period'=>/清/})
221
+ assert_equal("紹熙03(1192).01.10", When.when?('紹熙3.1.10').to_s) # , {'period'=>/清/})
222
+ assert_equal("崇徳03(1638).01.30", When.when?('崇徳3.1.30', {'period'=>/清/}).to_s)
223
+ assert_raises(ArgumentError) {When.when?('崇徳3.1.30', {'period'=>/後金/})}
224
+ assert_equal("正徳16(1521).03.14", When.TemporalPosition("正徳", 16, 3, 14, {"period"=>/明/}).to_s)
225
+ assert_equal("正徳16(1521).03.14", When.when?('正徳16.3.14', {'period'=>/明/}).to_s)
226
+ assert_equal("中国::明::崇禎11(1638).01.30",When.when?('崇禎11.1.30', {'period'=>/明/}).to_s)
227
+ end
228
+ end
229
+ end