when_exe 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.ja.txt +8 -21
  3. data/LICENSE.txt +5 -27
  4. data/README.md +25 -79
  5. data/bin/.pryrc +9 -0
  6. data/bin/make_ttl.rb +3 -2
  7. data/bin/make_ttl.rb.config +3 -3
  8. data/lib/when_exe.rb +101 -5
  9. data/lib/when_exe/basictypes.rb +47 -16
  10. data/lib/when_exe/calendarnote.rb +27 -18
  11. data/lib/when_exe/calendartypes.rb +12 -50
  12. data/lib/when_exe/coordinates.rb +37 -391
  13. data/lib/when_exe/ephemeris.rb +53 -14
  14. data/lib/when_exe/ephemeris/eclipse.rb +8 -8
  15. data/lib/when_exe/ephemeris/moon.rb +333 -333
  16. data/lib/when_exe/ephemeris/notes.rb +29 -17
  17. data/lib/when_exe/ephemeris/phase_table.rb +825 -0
  18. data/lib/when_exe/ephemeris/term_table.rb +603 -0
  19. data/lib/when_exe/events.rb +1888 -0
  20. data/lib/when_exe/google_api.rb +26 -31
  21. data/lib/when_exe/icalendar.rb +129 -12
  22. data/lib/when_exe/inspect.rb +5 -5
  23. data/lib/when_exe/linkeddata.rb +43 -23
  24. data/lib/when_exe/locales/akt.rb +63 -0
  25. data/lib/when_exe/locales/encoding_conversion.rb +134 -134
  26. data/lib/when_exe/locales/iast.rb +90 -90
  27. data/lib/when_exe/locales/locale.rb +88 -18
  28. data/lib/when_exe/locales/transliteration_table.rb +62 -62
  29. data/lib/when_exe/mini_application.rb +14 -8
  30. data/lib/when_exe/namespace.rb +42 -0
  31. data/lib/when_exe/parts/enumerator.rb +16 -5
  32. data/lib/when_exe/parts/geometric_complex.rb +52 -2
  33. data/lib/when_exe/parts/method_cash.rb +229 -224
  34. data/lib/when_exe/parts/resource.rb +65 -35
  35. data/lib/when_exe/parts/timezone.rb +25 -34
  36. data/lib/when_exe/region/balinese.rb +5 -3
  37. data/lib/when_exe/region/chinese.rb +39 -11
  38. data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
  39. data/lib/when_exe/region/chinese/epochs.rb +7 -7
  40. data/lib/when_exe/region/chinese/notes.rb +3 -3
  41. data/lib/when_exe/region/chinese/twins.rb +134 -11
  42. data/lib/when_exe/region/dee.rb +4 -4
  43. data/lib/when_exe/region/discordian.rb +1 -1
  44. data/lib/when_exe/region/geologicalage.rb +139 -128
  45. data/lib/when_exe/region/hanke_henry.rb +4 -4
  46. data/lib/when_exe/region/indian.rb +77 -8
  47. data/lib/when_exe/region/international_fixed.rb +3 -3
  48. data/lib/when_exe/region/islamic.rb +1 -1
  49. data/lib/when_exe/region/japanese.rb +12 -8
  50. data/lib/when_exe/region/japanese/calendars.rb +397 -397
  51. data/lib/when_exe/region/japanese/eclipses.rb +1194 -1194
  52. data/lib/when_exe/region/japanese/epochs.rb +8 -4
  53. data/lib/when_exe/region/japanese/location.rb +93 -0
  54. data/lib/when_exe/region/japanese/nihon_shoki.rb +70 -70
  55. data/lib/when_exe/region/japanese/notes.rb +57 -18
  56. data/lib/when_exe/region/japanese/residues.rb +33 -11
  57. data/lib/when_exe/region/japanese/twins.rb +27 -14
  58. data/lib/when_exe/region/japanese/weeks.rb +7 -7
  59. data/lib/when_exe/region/korean.rb +384 -384
  60. data/lib/when_exe/region/location.rb +40 -0
  61. data/lib/when_exe/region/martian.rb +1 -1
  62. data/lib/when_exe/region/mayan.rb +2 -2
  63. data/lib/when_exe/region/roman.rb +2 -2
  64. data/lib/when_exe/region/ryukyu.rb +101 -101
  65. data/lib/when_exe/region/saudi_arabian.rb +57 -0
  66. data/lib/when_exe/region/shire.rb +1 -1
  67. data/lib/when_exe/region/world.rb +3 -3
  68. data/lib/when_exe/region/zoroastrian.rb +1 -1
  69. data/lib/when_exe/spatial.rb +611 -0
  70. data/lib/when_exe/timestandard.rb +9 -7
  71. data/lib/when_exe/tmobjects.rb +34 -2
  72. data/lib/when_exe/tmposition.rb +225 -1322
  73. data/lib/when_exe/tmptypes.rb +1279 -0
  74. data/lib/when_exe/tmreference.rb +42 -7
  75. data/lib/when_exe/version.rb +3 -3
  76. data/test/events/example-datasets +6 -0
  77. data/test/events/history-dataset.csv +22 -0
  78. data/test/events/japanese-holiday-index.csv +28 -0
  79. data/test/events/japanese-holiday.csv +94 -0
  80. data/test/events/japanese-holiday.ttl +948 -0
  81. data/test/events/make_events_ttl.rb +18 -0
  82. data/test/events/mori_wikichoshi.csv +14 -0
  83. data/test/events/ndl_koyomi.csv +220 -0
  84. data/test/events/ndl_koyomi_index.csv +44 -0
  85. data/test/events/primeminister-dataset.csv +19 -0
  86. data/test/events/shogun-dataset.csv +22 -0
  87. data/test/events/test-history-dataset-edge-sparql.csv +26 -0
  88. data/test/events/test-history-dataset-edge.csv +27 -0
  89. data/test/events/test-history-dataset-sparql.csv +22 -0
  90. data/test/events/test-history-dataset.csv +23 -0
  91. data/test/events/test-history-events-edge.ttl +89 -0
  92. data/test/events/test-history-events.csv +6 -0
  93. data/test/examples/JapanHolidays.ics +2 -2
  94. data/test/examples/JapanHolidaysRFC6350.ics +3 -3
  95. data/test/examples/Residue.m17n +2 -2
  96. data/test/examples/Spatial.m17n +3 -3
  97. data/test/examples/Terms.m17n +3 -3
  98. data/test/scripts/8.ext.rb +6 -6
  99. data/test/scripts/8.rb +6 -6
  100. data/test/scripts/geometric_complex.rb +41 -41
  101. data/test/scripts/korea.rb +59 -59
  102. data/test/scripts/thai.rb +36 -36
  103. data/test/test.rb +6 -0
  104. data/test/test/basictypes.rb +431 -431
  105. data/test/test/calendarnote.rb +86 -86
  106. data/test/test/calendartypes.rb +97 -97
  107. data/test/test/coordinates.rb +399 -397
  108. data/test/test/ephemeris.rb +115 -115
  109. data/test/test/ephemeris/moon.rb +14 -14
  110. data/test/test/ephemeris/planets.rb +14 -14
  111. data/test/test/ephemeris/sun.rb +14 -14
  112. data/test/test/events.rb +32 -0
  113. data/test/test/google_api.rb +45 -32
  114. data/test/test/inspect.rb +153 -153
  115. data/test/test/parts.rb +488 -488
  116. data/test/test/region/armenian.rb +20 -20
  117. data/test/test/region/bahai.rb +58 -58
  118. data/test/test/region/balinese.rb +34 -34
  119. data/test/test/region/chinese.rb +229 -229
  120. data/test/test/region/christian.rb +226 -226
  121. data/test/test/region/coptic.rb +27 -27
  122. data/test/test/region/discordian.rb +20 -20
  123. data/test/test/region/french.rb +33 -33
  124. data/test/test/region/geologicalage.rb +17 -17
  125. data/test/test/region/indian.rb +14 -1
  126. data/test/test/region/iran.rb +54 -54
  127. data/test/test/region/islamic.rb +64 -54
  128. data/test/test/region/japanese.rb +281 -261
  129. data/test/test/region/jewish.rb +63 -63
  130. data/test/test/region/m17n.rb +21 -21
  131. data/test/test/region/mayan.rb +17 -16
  132. data/test/test/region/reforms.rb +2 -2
  133. data/test/test/region/residue.rb +7 -7
  134. data/test/test/region/shire.rb +58 -58
  135. data/test/test/region/swedish.rb +45 -45
  136. data/test/test/region/thai.rb +116 -116
  137. data/test/test/region/tibetan.rb +30 -30
  138. data/test/test/region/vietnamese.rb +102 -102
  139. data/test/test/region/zoroastrian.rb +58 -58
  140. data/test/test/timestandard.rb +81 -81
  141. data/test/test/tmobjects.rb +402 -402
  142. data/test/test/tmposition.rb +66 -4
  143. data/test/test/tmreference.rb +157 -157
  144. metadata +36 -93
@@ -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 Discordian < MiniTest::TestCase
12
- def test_discordian
13
- date = When.when? '2001.1.1'
14
- 400.times do |i|
15
- assert_equal([2001+i+1166,1,1], (When::Discordian ^ date).cal_date)
16
- date += When::P1Y
17
- end
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 Discordian < MiniTest::TestCase
12
+ def test_discordian
13
+ date = When.when? '2001.1.1'
14
+ 400.times do |i|
15
+ assert_equal([2001+i+1166,1,1], (When::Discordian ^ date).cal_date)
16
+ date += When::P1Y
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,33 +1,33 @@
1
- # -*- coding: utf-8 -*-
2
- =begin
3
- Copyright (C) 2012 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 FrenchRepublican < MiniTest::TestCase
12
- def test__french_republican
13
- date = When.when? '1.1.1^^FrenchRepublican'
14
- [["0001-01-01", 2375840],
15
- ["0002-01-01", 2376205],
16
- ["0003-01-01", 2376570],
17
- ["0004-01-01", 2376936],
18
- ["0005-01-01", 2377301],
19
- ["0006-01-01", 2377666],
20
- ["0007-01-01", 2378031],
21
- ["0008-01-01", 2378397],
22
- ["0009-01-01", 2378762],
23
- ["0010-01-01", 2379127],
24
- ["0011-01-01", 2379492],
25
- ["0012-01-01", 2379858],
26
- ["0013-01-01", 2380223],
27
- ["0014-01-01", 2380588]].each do |sample|
28
- assert_equal(sample, [date.to_s, date.to_i])
29
- date += When::P1Y
30
- end
31
- end
32
- end
33
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2012 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 FrenchRepublican < MiniTest::TestCase
12
+ def test__french_republican
13
+ date = When.when? '1.1.1^^FrenchRepublican'
14
+ [["0001-01-01", 2375840],
15
+ ["0002-01-01", 2376205],
16
+ ["0003-01-01", 2376570],
17
+ ["0004-01-01", 2376936],
18
+ ["0005-01-01", 2377301],
19
+ ["0006-01-01", 2377666],
20
+ ["0007-01-01", 2378031],
21
+ ["0008-01-01", 2378397],
22
+ ["0009-01-01", 2378762],
23
+ ["0010-01-01", 2379127],
24
+ ["0011-01-01", 2379492],
25
+ ["0012-01-01", 2379858],
26
+ ["0013-01-01", 2380223],
27
+ ["0014-01-01", 2380588]].each do |sample|
28
+ assert_equal(sample, [date.to_s, date.to_i])
29
+ date += When::P1Y
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,17 +1,17 @@
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::TM
10
- class GeologicalAge < MiniTest::TestCase
11
- def test__geological_age
12
- age = When.Resource('_tm:OrdinalReferenceSystem/GeologicalAge')
13
- assert_equal("-2500000000", age['始生代::新始生代'].end.to_s)
14
- assert_equal("-09700", age['顕生代::新生代::第四紀::完新世'].begin.to_s)
15
- end
16
- end
17
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2011-2015 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::TM
10
+ class GeologicalAge < MiniTest::TestCase
11
+ def test__geological_age
12
+ age = When.Resource('_tm:OrdinalReferenceSystem/GeologicalAge')
13
+ assert_equal("-2500000000", age['Archean::Neoarchean'].end.to_s)
14
+ assert_equal("-09700", age['Phanerozoic::Cenozoic::Quaternary::Holocene'].begin.to_s)
15
+ end
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2015 Takashi SUGA
3
+ Copyright (C) 2011-2018 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license
6
6
  described in the LICENSE.txt file included in this archive.
@@ -86,5 +86,18 @@ module MiniTest
86
86
  date = When.when? '1936-11%3C08-%5E%5eHinduLuniSolar?note=HinduNote&location=(_co:Indian::Chennai)&start_month=5&type=SBSA'
87
87
  assert_equal('1936-11<08-', date.to_s)
88
88
  end
89
+
90
+ def test_vikram_sambat
91
+ date = When.when? '1942.4.20'
92
+ mismatches = []
93
+ 961.times do
94
+ sambat = (When::VikramSambatSolar ^ date).to_s
95
+ samvat = (When::VikramSamvatSolar ^ date).to_s
96
+ mismatches << [date.to_s, sambat, samvat] unless sambat == samvat
97
+ date += When::P1M
98
+ end
99
+ assert_equal([%w(1945-11-20 2002-08-06 2002-08-05)], mismatches)
100
+ end
101
+
89
102
  end
90
103
  end
@@ -1,54 +1,54 @@
1
- # -*- coding: utf-8 -*-
2
- =begin
3
- Copyright (C) 2012 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 Iranian < MiniTest::TestCase
12
- def test__iranian
13
- date = When.when? 'AP1391.1.1'
14
- [["Iranian::AH1391.01.01", 2456007], # (2012)
15
- ["Iranian::AH1392.01.01", 2456373], # (2013)
16
- ["Iranian::AH1393.01.01", 2456738], # (2014)
17
- ["Iranian::AH1394.01.01", 2457103], # (2015)
18
- ["Iranian::AH1395.01.01", 2457468], # (2016)
19
- ["Iranian::AH1396.01.01", 2457834], # (2017)
20
- ["Iranian::AH1397.01.01", 2458199], # (2018)
21
- ["Iranian::AH1398.01.01", 2458564], # (2019)
22
- ["Iranian::AH1399.01.01", 2458929], # (2020)
23
- ["Iranian::AH1400.01.01", 2459295], # (2021)
24
- ["Iranian::AH1401.01.01", 2459660], # (2022)
25
- ["Iranian::AH1402.01.01", 2460025], # (2023)
26
- ["Iranian::AH1403.01.01", 2460390], # (2024)
27
- ["Iranian::AH1404.01.01", 2460756], # (2025)
28
- ["Iranian::AH1405.01.01", 2461121], # (2026)
29
- ["Iranian::AH1406.01.01", 2461486], # (2027)
30
- ["Iranian::AH1407.01.01", 2461851], # (2028)
31
- ["Iranian::AH1408.01.01", 2462216], # (2029)
32
- ["Iranian::AH1409.01.01", 2462582], # (2030)
33
- ["Iranian::AH1410.01.01", 2462947], # (2031)
34
- ["Iranian::AH1411.01.01", 2463312], # (2032)
35
- ["Iranian::AH1412.01.01", 2463677], # (2033)
36
- ["Iranian::AH1413.01.01", 2464043], # (2034)
37
- ["Iranian::AH1414.01.01", 2464408], # (2035)
38
- ["Iranian::AH1415.01.01", 2464773], # (2036)
39
- ["Iranian::AH1416.01.01", 2465138], # (2037)
40
- ["Iranian::AH1417.01.01", 2465504], # (2038)
41
- ["Iranian::AH1418.01.01", 2465869], # (2039)
42
- ["Iranian::AH1419.01.01", 2466234], # (2040)
43
- ["Iranian::AH1420.01.01", 2466599], # (2041)
44
- ["Iranian::AH1421.01.01", 2466965], # (2042)
45
- ["Iranian::AH1422.01.01", 2467330], # (2043)
46
- ["Iranian::AH1423.01.01", 2467695], # (2044)
47
- ["Iranian::AH1424.01.01", 2468060] # (2045)
48
- ].each do |sample|
49
- assert_equal(sample, [date.to_s, date.to_i])
50
- date += When.Duration('P1Y')
51
- end
52
- end
53
- end
54
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2012 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 Iranian < MiniTest::TestCase
12
+ def test__iranian
13
+ date = When.when? 'AP1391.1.1'
14
+ [["Iranian::AH1391.01.01", 2456007], # (2012)
15
+ ["Iranian::AH1392.01.01", 2456373], # (2013)
16
+ ["Iranian::AH1393.01.01", 2456738], # (2014)
17
+ ["Iranian::AH1394.01.01", 2457103], # (2015)
18
+ ["Iranian::AH1395.01.01", 2457468], # (2016)
19
+ ["Iranian::AH1396.01.01", 2457834], # (2017)
20
+ ["Iranian::AH1397.01.01", 2458199], # (2018)
21
+ ["Iranian::AH1398.01.01", 2458564], # (2019)
22
+ ["Iranian::AH1399.01.01", 2458929], # (2020)
23
+ ["Iranian::AH1400.01.01", 2459295], # (2021)
24
+ ["Iranian::AH1401.01.01", 2459660], # (2022)
25
+ ["Iranian::AH1402.01.01", 2460025], # (2023)
26
+ ["Iranian::AH1403.01.01", 2460390], # (2024)
27
+ ["Iranian::AH1404.01.01", 2460756], # (2025)
28
+ ["Iranian::AH1405.01.01", 2461121], # (2026)
29
+ ["Iranian::AH1406.01.01", 2461486], # (2027)
30
+ ["Iranian::AH1407.01.01", 2461851], # (2028)
31
+ ["Iranian::AH1408.01.01", 2462216], # (2029)
32
+ ["Iranian::AH1409.01.01", 2462582], # (2030)
33
+ ["Iranian::AH1410.01.01", 2462947], # (2031)
34
+ ["Iranian::AH1411.01.01", 2463312], # (2032)
35
+ ["Iranian::AH1412.01.01", 2463677], # (2033)
36
+ ["Iranian::AH1413.01.01", 2464043], # (2034)
37
+ ["Iranian::AH1414.01.01", 2464408], # (2035)
38
+ ["Iranian::AH1415.01.01", 2464773], # (2036)
39
+ ["Iranian::AH1416.01.01", 2465138], # (2037)
40
+ ["Iranian::AH1417.01.01", 2465504], # (2038)
41
+ ["Iranian::AH1418.01.01", 2465869], # (2039)
42
+ ["Iranian::AH1419.01.01", 2466234], # (2040)
43
+ ["Iranian::AH1420.01.01", 2466599], # (2041)
44
+ ["Iranian::AH1421.01.01", 2466965], # (2042)
45
+ ["Iranian::AH1422.01.01", 2467330], # (2043)
46
+ ["Iranian::AH1423.01.01", 2467695], # (2044)
47
+ ["Iranian::AH1424.01.01", 2468060] # (2045)
48
+ ].each do |sample|
49
+ assert_equal(sample, [date.to_s, date.to_i])
50
+ date += When.Duration('P1Y')
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,54 +1,64 @@
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
- module CalendarTypes
12
- class Islamic < MiniTest::TestCase
13
-
14
- Sample = [
15
- ["1435-01-01", 2456602],["1435-02-01", 2456632],["1435-03-01", 2456661],["1435-04-01", 2456691],
16
- ["1435-05-01", 2456720],["1435-06-01", 2456750],["1435-07-01", 2456779],["1435-08-01", 2456809],
17
- ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456897],["1435-12-01", 2456927],
18
-
19
- ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457045],
20
- ["1436-05-01", 2457074],["1436-06-01", 2457104],["1436-07-01", 2457133],["1436-08-01", 2457163],
21
- ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],
22
-
23
- ["1437-01-01", 2457311],["1437-02-01", 2457341],["1437-03-01", 2457370],["1437-04-01", 2457400],
24
- ["1437-05-01", 2457429],["1437-06-01", 2457459],["1437-07-01", 2457488],["1437-08-01", 2457518],
25
- ["1437-09-01", 2457547],["1437-10-01", 2457577],["1437-11-01", 2457606],["1437-12-01", 2457636],
26
-
27
-
28
- ["1435-01-01", 2456602],["1435-02-01", 2456631],["1435-03-01", 2456660],["1435-04-01", 2456690],
29
- ["1435-05-01", 2456719],["1435-06-01", 2456749],["1435-07-01", 2456778],["1435-08-01", 2456808],
30
- ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456898],["1435-12-01", 2456927],
31
-
32
- ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457044],
33
- ["1436-05-01", 2457074],["1436-06-01", 2457103],["1436-07-01", 2457133],["1436-08-01", 2457162],
34
- ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],
35
-
36
- ["1437-01-01", 2457310],["1437-02-01", 2457340],["1437-03-01", 2457370],["1437-04-01", 2457399],
37
- ["1437-05-01", 2457429],["1437-06-01", 2457458],["1437-07-01", 2457487],["1437-08-01", 2457517],
38
- ["1437-09-01", 2457546],["1437-10-01", 2457576],["1437-11-01", 2457605],["1437-12-01", 2457635],
39
- ]
40
-
41
- def test_islamic_date
42
- sample = Sample.dup
43
- %w(TabularIslamic EphemerisBasedIslamic?long=140.5200E&lat=38.1560N).each do |frame|
44
- date = When.when?('1435-1-1', :frame=>frame)
45
- 36.times do
46
- assert_equal(sample.shift, [date.to_s, date.to_i])
47
- date += When::P1M
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2011-2017 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
+ module CalendarTypes
12
+ class Islamic < MiniTest::TestCase
13
+
14
+ Sample = [
15
+ ["1435-01-01", 2456602],["1435-02-01", 2456632],["1435-03-01", 2456661],["1435-04-01", 2456691],
16
+ ["1435-05-01", 2456720],["1435-06-01", 2456750],["1435-07-01", 2456779],["1435-08-01", 2456809],
17
+ ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456897],["1435-12-01", 2456927],
18
+
19
+ ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457045],
20
+ ["1436-05-01", 2457074],["1436-06-01", 2457104],["1436-07-01", 2457133],["1436-08-01", 2457163],
21
+ ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],
22
+
23
+ ["1437-01-01", 2457311],["1437-02-01", 2457341],["1437-03-01", 2457370],["1437-04-01", 2457400],
24
+ ["1437-05-01", 2457429],["1437-06-01", 2457459],["1437-07-01", 2457488],["1437-08-01", 2457518],
25
+ ["1437-09-01", 2457547],["1437-10-01", 2457577],["1437-11-01", 2457606],["1437-12-01", 2457636],
26
+
27
+
28
+ ["1435-01-01", 2456602],["1435-02-01", 2456631],["1435-03-01", 2456660],["1435-04-01", 2456690],
29
+ ["1435-05-01", 2456719],["1435-06-01", 2456749],["1435-07-01", 2456778],["1435-08-01", 2456808],
30
+ ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456898],["1435-12-01", 2456927],
31
+
32
+ ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457044],
33
+ ["1436-05-01", 2457074],["1436-06-01", 2457103],["1436-07-01", 2457133],["1436-08-01", 2457162],
34
+ ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],
35
+
36
+ ["1437-01-01", 2457310],["1437-02-01", 2457340],["1437-03-01", 2457370],["1437-04-01", 2457399],
37
+ ["1437-05-01", 2457429],["1437-06-01", 2457458],["1437-07-01", 2457487],["1437-08-01", 2457517],
38
+ ["1437-09-01", 2457546],["1437-10-01", 2457576],["1437-11-01", 2457605],["1437-12-01", 2457635],
39
+ ]
40
+
41
+ def test_islamic_date
42
+ sample = Sample.dup
43
+ %w(TabularIslamic EphemerisBasedIslamic?long=140.5200E&lat=38.1560N).each do |frame|
44
+ date = When.when?('1435-1-1', :frame=>frame)
45
+ 36.times do
46
+ assert_equal(sample.shift, [date.to_s, date.to_i])
47
+ date += When::P1M
48
+ end
49
+ end
50
+ end
51
+
52
+ def test_ummalqura_solar
53
+ date = When.when? '2017.9.23'
54
+ assert_equal('1396-01-01', (When::UmmalquraSolar ^ date).to_s)
55
+ 399.times do
56
+ date += When::P1Y
57
+ assert_equal([1,1], (When::UmmalquraSolar ^ date).cal_date[-2..-1])
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+
64
+ end
@@ -1,261 +1,281 @@
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 Japanese < MiniTest::TestCase
12
-
13
- include When::CalendarNote::Japanese::Index
14
- Masks = MD廿四節気|MD七十二候|MD六十卦|MD没|MD往亡
15
-
16
- def test_japanese_epoch
17
- eras = When.Resource('_e:Japanese')
18
-
19
- sample =
20
- [["天平21(0749).04.13", "天平感宝01(0749).04.13", "天平勝宝01(0749).04.13"],
21
- ["天平21(0749).04.13"],
22
- ["天平感宝01(0749).04.14", "天平勝宝01(0749).04.14"],
23
- ["天平感宝01(0749).04.14"],
24
- ["天平勝宝01(0749).07.02"],
25
- ["天平勝宝01(0749).07.02"]]
26
- ['天平勝宝01.04.13', '天平勝宝01.04.14', '天平勝宝01.07.02'].each do |string|
27
- assert_equal(sample.shift, ((When.when?(string) ^ eras).
28
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
29
- assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
30
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
31
- end
32
-
33
- sample =
34
- [["大正15(1926).12.24"],
35
- ["大正15(1926).12.24"],
36
- ["昭和01(1926).12.25"],
37
- ["昭和01(1926).12.25"],
38
- ["昭和01(1926).12.26"],
39
- ["昭和01(1926).12.26"]]
40
- ['大正15.12.24', '大正15.12.25', '大正15.12.26'].each do |string|
41
- assert_equal(sample.shift, ((When.when?(string) ^ eras).
42
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
43
- assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
44
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
45
- end
46
- end
47
-
48
- def test__solar_terms
49
- sample = [
50
- [ # 修正後
51
- ["貞観12(0870).07.17T+00", []],
52
- ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損", "没"]],
53
- ["貞観12(0870).07.19T+00", []],
54
-
55
- ["天喜05(1057).03.10T+00", []],
56
- ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
57
- ["天喜05(1057).03.12T+00", []],
58
-
59
- ["建仁02(1202).10=29T+00", ["没"]],
60
- ["建仁02(1202).11.01T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
61
- ["建仁02(1202).11.02T+00", []],
62
- ["建仁02(1202).11.03T+00", []],
63
-
64
- ["寛元01(1243).11.03T+00", []],
65
- ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚", "没"]],
66
- ["寛元01(1243).11.05T+00", []],
67
-
68
- ["弘安04(1281).07=30T+00", ["没"]],
69
- ["弘安04(1281).08.01T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
70
- ["弘安04(1281).08.02T+00", []],
71
-
72
- ["永享02(1430).07.11T+00", ["没"]],
73
- ["永享02(1430).07.12T+00", []],
74
- ["永享02(1430).07.13T+00", []],
75
- ["永享02(1430).07.14T+00", ["大夫節"]],
76
- ["永享02(1430).07.15T+00", []],
77
- ["永享02(1430).07.16T+00", ["白露降"]],
78
- ["永享02(1430).07.17T+00", []],
79
- ["永享02(1430).07.18T+00", []],
80
- ["永享02(1430).07.19T+00", ["往亡"]],
81
- ["永享02(1430).07.20T+00", ["卿同人"]],
82
- ["永享02(1430).07.21T+00", ["寒蟬鳴"]],
83
- ["永享02(1430).07.22T+00", []],
84
- ["永享02(1430).07.23T+00", []],
85
- ["永享02(1430).07.24T+00", []],
86
- ["永享02(1430).07.25T+00", []],
87
-
88
- ["元和03(1617).03.18T+00", []],
89
- ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
90
- ["元和03(1617).03.20T+00", []],
91
-
92
- ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
93
- ["平成06(1994).06.22T+09:00", []]
94
- ],
95
-
96
- [ # 修正前
97
- ["貞観12(0870).07.17T+00", ["没"]],
98
- ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損"]],
99
- ["貞観12(0870).07.19T+00", []],
100
-
101
- ["天喜05(1057).03.10T+00", ["没"]],
102
- ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革"]],
103
- ["天喜05(1057).03.12T+00", []],
104
-
105
- ["建仁02(1202).10=29T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
106
- ["建仁02(1202).11.01T+00", []],
107
- ["建仁02(1202).11.02T+00", []],
108
- ["建仁02(1202).11.03T+00", ["没"]],
109
-
110
- ["寛元01(1243).11.03T+00", ["没"]],
111
- ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
112
- ["寛元01(1243).11.05T+00", []],
113
-
114
- ["弘安04(1281).07=30T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
115
- ["弘安04(1281).08.01T+00", []],
116
- ["弘安04(1281).08.02T+00", ["没"]],
117
-
118
- ["永享02(1430).07.11T+00", []],
119
- ["永享02(1430).07.12T+00", []],
120
- ["永享02(1430).07.13T+00", ["大夫節"]],
121
- ["永享02(1430).07.14T+00", []],
122
- ["永享02(1430).07.15T+00", ["白露降"]],
123
- ["永享02(1430).07.16T+00", []],
124
- ["永享02(1430).07.17T+00", []],
125
- ["永享02(1430).07.18T+00", ["往亡"]],
126
- ["永享02(1430).07.19T+00", ["卿同人"]],
127
- ["永享02(1430).07.20T+00", ["寒蟬鳴"]],
128
- ["永享02(1430).07.21T+00", []],
129
- ["永享02(1430).07.22T+00", []],
130
- ["永享02(1430).07.23T+00", []],
131
- ["永享02(1430).07.24T+00", []],
132
- ["永享02(1430).07.25T+00", ["没"]],
133
-
134
- ["元和03(1617).03.18T+00", ["没"]],
135
- ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革"]],
136
- ["元和03(1617).03.20T+00", []],
137
-
138
- ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
139
- ["平成06(1994).06.22T+09:00", []]
140
- ]
141
- ]
142
-
143
- 2.times do
144
- result = []
145
- [2039054..2039056,
146
- 2107233..2107235,
147
- 2160437..2160440,
148
- 2175412..2175414,
149
- 2189200..2189202,
150
- 2243577..2243591,
151
- 2311770..2311772,
152
- 2449525..2449526].each do |range|
153
- range.each do |jdn|
154
- (When.when?(jdn) ^ When.CalendarEra('Japanese')).each do |date|
155
- dates = When.CalendarNote('Japanese').send(:_to_date_for_note, date)
156
- date = When.when?(dates.o_date.to_cal_date.to_s,
157
- {:clock=>dates.s_date.frame.time_basis})
158
- long = dates.cal4note.s_terms.position(date)
159
- notes = date.notes(:indices => When::DAY,
160
- :notes => Masks,
161
- :locale => 'ja').simplify[:value].compact
162
- result << [date.to_m17n/'ja', notes]
163
- end
164
- end
165
- end
166
- assert_equal(sample.shift, result)
167
- When::CalendarNote::Japanese::SolarTerms.send(:patch=, {})
168
- end
169
- When::CalendarNote::Japanese::SolarTerms.send(:patch=, nil)
170
-
171
- assert_equal('白露(135.375/560)',
172
- When.when?('康和1.8.14').notes(:notes=>'廿四節気', :shoyo=>true)[:value].simplify.to_s)
173
-
174
- end
175
-
176
- def test__lunar_phases
177
- [%w(康和3.01.09 康和3.01.16 康和3.01.23),
178
- %w(康和3.02.08 康和3.02.16 康和3.02.23),
179
- %w(康和3.03.08 康和3.03.15 康和3.03.22),
180
- %w(康和3.04.09 康和3.04.16 康和3.04.23),
181
- %w(康和3.05.08 康和3.05.15 康和3.05.22),
182
- %w(康和3.06.08 康和3.06.15 康和3.06.23),
183
- %w(康和3.07.08 康和3.07.15 康和3.07.22),
184
- %w(康和3.08.07 康和3.08.14 康和3.08.22),
185
- %w(康和3.09.07 康和3.09.15 康和3.09.23),
186
- %w(康和3.10.08 康和3.10.15 康和3.10.23),
187
- %w(康和3.11.07 康和3.11.15 康和3.11.23),
188
- %w(康和3.12.08 康和3.12.16 康和3.12.23),
189
-
190
- %w(平成26.01.01 平成26.01.08 平成26.01.16 平成26.01.24),
191
- %w(平成26.01.31 平成26.02.07 平成26.02.15 平成26.02.23),
192
- %w(平成26.03.01 平成26.03.08 平成26.03.17 平成26.03.24),
193
- %w(平成26.03.31 平成26.04.07 平成26.04.15 平成26.04.22),
194
- %w(平成26.04.29 平成26.05.07 平成26.05.15 平成26.05.21),
195
- %w(平成26.05.29 平成26.06.06 平成26.06.13 平成26.06.20),
196
- %w(平成26.06.27 平成26.07.05 平成26.07.12 平成26.07.19),
197
- %w(平成26.07.27 平成26.08.04 平成26.08.11 平成26.08.17),
198
- %w(平成26.08.25 平成26.09.02 平成26.09.09 平成26.09.16),
199
- %w(平成26.09.24 平成26.10.02 平成26.10.08 平成26.10.16),
200
- %w(平成26.10.24 平成26.10.31 平成26.11.07 平成26.11.15),
201
- %w(平成26.11.22 平成26.11.29 平成26.12.06 平成26.12.14),
202
- %w(平成26.12.22 平成26.12.29)
203
- ].each do |month|
204
- assert_equal([true], month.map {|date| When.when?(date).is?('月相')}.uniq)
205
- end
206
- end
207
-
208
- def test__eclipse
209
- date = When.when?('貞観4.2.1')
210
- assert_equal('夜日蝕七分', date.notes({:notes=>'日食'}).value)
211
- assert_equal(nil, date.notes({:notes=>'日食', :solar_eclipse=>1}).value)
212
-
213
- date = When.when?('貞観4.2.15')
214
- assert_equal('(月蝕ニ分)', date.notes({:notes=>'月食'}).value)
215
- assert_equal(nil, date.notes({:notes=>'月食', :lunar_eclipse=>3}).value)
216
- end
217
-
218
- def test_japanese_lunisolar
219
- assert_equal({1850=>{"hI"=>"Hi"}, 1866=>{"cD"=>"Cd"}, 1884=>{"cD"=>"Cd"}, 1947=>{"b"=>"c"}},
220
- When.Calendar('Japanese').verify(When.Calendar('JapaneseTwin::旧暦'), 1844..2033))
221
- end
222
-
223
- def test_japanese_era
224
- assert_raises(RangeError) {When.TemporalPosition("正慶", 2, 11)}
225
- assert_equal("延元02(1337).01.08", When.when?("建武4.1.8").to_s)
226
- assert_equal("延元02(1337).01.08", When.TemporalPosition("建武", 4, 1, 8, {:invalid=>:non}).to_s)
227
- assert_equal("<神武>03(-657).01.30", When.when?('神武3.1.30').to_s) # , {'period'=>/清/})
228
- assert_equal("日本::皇紀2600(1940).01.30", When.when?('皇紀2600.1.30').to_s) # , {'period'=>/清/})
229
- assert_equal("応永11(1404).12.10", When.when?('嘉慶18.12.10').to_s)
230
- assert_equal("明治01(1868).09.08", When.when?('明治1(1868).09.08').to_s)
231
- assert_equal("天保03(0564).10.01", When.when?('天保3.10.01', {'period'=>/梁/}).to_s)
232
- assert_equal(%w(元暦 文治 建久 正治 建仁 元久 建永 承元 建暦 建保
233
- 承久 貞応 元仁 嘉禄 安貞 寛喜 貞永 天福 文暦 嘉禎
234
- 暦仁 延応 仁治 寛元 宝治 建長 康元 正嘉 正元 文応
235
- 弘長 文永 建治 弘安 正応 永仁 正安 乾元 嘉元 徳治
236
- 延慶 応長 正和 文保 元応 元亨 正中 嘉暦 元徳 元弘),
237
- When.era('鎌倉時代')[0].map { |era| era.label.to_s})
238
-
239
- date = When.when?('768-10-20^^Gregorian')
240
- assert_equal('神護景雲02(0768).09.02', (date ^ When.CalendarEra('Japanese'))[0].to_s)
241
- assert_equal('日本?V=0764::奈良時代::神護景雲02(0768).09.01', (date ^ When.CalendarEra('Japanese?V=0764'))[0].to_s)
242
- assert_equal('日本::奈良時代::神護景雲02(0768).09.02', (date ^ When.CalendarEra('Japanese'))[0].to_s)
243
- end
244
- =begin
245
- def test_japanese_date
246
- jc = When.Resource('_c:Japanese')
247
- diff = []
248
- open('test/region/japanese-calendar.txt', "1".respond_to?(:force_encoding) ? 'r:utf-8' : 'r') do |f|
249
- while (line = f.gets)
250
- next if line =~ /\A *#/
251
- x, x, jdn, x, x, x, gy, gm, gd, x, x, jy, jm, jd = line.split(/ +/).map {|v| v.to_i}
252
- jm, leap = (jm > 0) ? [jm, '-'] : [-jm, '=']
253
- date = When.when?("%04d-%02d%s%02d" % [(gm >= jm) ? gy : gy-1, jm, leap, jd], {:frame=>jc})
254
- diff << [jdn - date.to_i, date.to_s] unless jdn == date.to_i
255
- end
256
- end
257
- assert_equal([], diff)
258
- end
259
- =end
260
- end
261
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2011-2020 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 Japanese < MiniTest::TestCase
12
+
13
+ include When::CalendarNote::Japanese::Index
14
+ Masks = MD廿四節気|MD七十二候|MD六十卦|MD没|MD往亡
15
+
16
+ def test_japanese_epoch
17
+ eras = When.Resource('_e:Japanese')
18
+
19
+ sample =
20
+ [["天平21(0749).04.13", "天平感宝01(0749).04.13", "天平勝宝01(0749).04.13"],
21
+ ["天平21(0749).04.13"],
22
+ ["天平感宝01(0749).04.14", "天平勝宝01(0749).04.14"],
23
+ ["天平感宝01(0749).04.14"],
24
+ ["天平勝宝01(0749).07.02"],
25
+ ["天平勝宝01(0749).07.02"]]
26
+ ['天平勝宝01.04.13', '天平勝宝01.04.14', '天平勝宝01.07.02'].each do |string|
27
+ assert_equal(sample.shift, ((When.when?(string) ^ eras).
28
+ delete_if {|d| !d.leaf?}).map {|d| d.to_s})
29
+ assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
30
+ delete_if {|d| !d.leaf?}).map {|d| d.to_s})
31
+ end
32
+
33
+ sample =
34
+ [["大正15(1926).12.24"],
35
+ ["大正15(1926).12.24"],
36
+ ["昭和01(1926).12.25"],
37
+ ["昭和01(1926).12.25"],
38
+ ["昭和01(1926).12.26"],
39
+ ["昭和01(1926).12.26"]]
40
+ ['大正15.12.24', '大正15.12.25', '大正15.12.26'].each do |string|
41
+ assert_equal(sample.shift, ((When.when?(string) ^ eras).
42
+ delete_if {|d| !d.leaf?}).map {|d| d.to_s})
43
+ assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
44
+ delete_if {|d| !d.leaf?}).map {|d| d.to_s})
45
+ end
46
+ end
47
+
48
+ def test__solar_terms
49
+ sample = [
50
+ [ # 修正後
51
+ ["貞観12(0870).07.17T+00", []],
52
+ ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損", "没"]],
53
+ ["貞観12(0870).07.19T+00", []],
54
+
55
+ ["天喜05(1057).03.10T+00", []],
56
+ ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
57
+ ["天喜05(1057).03.12T+00", []],
58
+
59
+ ["建仁02(1202).10=29T+00", ["没"]],
60
+ ["建仁02(1202).11.01T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
61
+ ["建仁02(1202).11.02T+00", []],
62
+ ["建仁02(1202).11.03T+00", []],
63
+
64
+ ["寛元01(1243).11.03T+00", []],
65
+ ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚", "没"]],
66
+ ["寛元01(1243).11.05T+00", []],
67
+
68
+ ["弘安04(1281).07=30T+00", ["没"]],
69
+ ["弘安04(1281).08.01T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
70
+ ["弘安04(1281).08.02T+00", []],
71
+
72
+ ["永享02(1430).07.11T+00", ["没"]],
73
+ ["永享02(1430).07.12T+00", []],
74
+ ["永享02(1430).07.13T+00", []],
75
+ ["永享02(1430).07.14T+00", ["大夫節"]],
76
+ ["永享02(1430).07.15T+00", []],
77
+ ["永享02(1430).07.16T+00", ["白露降"]],
78
+ ["永享02(1430).07.17T+00", []],
79
+ ["永享02(1430).07.18T+00", []],
80
+ ["永享02(1430).07.19T+00", ["往亡"]],
81
+ ["永享02(1430).07.20T+00", ["卿同人"]],
82
+ ["永享02(1430).07.21T+00", ["寒蟬鳴"]],
83
+ ["永享02(1430).07.22T+00", []],
84
+ ["永享02(1430).07.23T+00", []],
85
+ ["永享02(1430).07.24T+00", []],
86
+ ["永享02(1430).07.25T+00", []],
87
+
88
+ ["元和03(1617).03.18T+00", []],
89
+ ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
90
+ ["元和03(1617).03.20T+00", []],
91
+
92
+ ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
93
+ ["平成06(1994).06.22T+09:00", []]
94
+ ],
95
+
96
+ [ # 修正前
97
+ ["貞観12(0870).07.17T+00", ["没"]],
98
+ ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損"]],
99
+ ["貞観12(0870).07.19T+00", []],
100
+
101
+ ["天喜05(1057).03.10T+00", ["没"]],
102
+ ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革"]],
103
+ ["天喜05(1057).03.12T+00", []],
104
+
105
+ ["建仁02(1202).10=29T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
106
+ ["建仁02(1202).11.01T+00", []],
107
+ ["建仁02(1202).11.02T+00", []],
108
+ ["建仁02(1202).11.03T+00", ["没"]],
109
+
110
+ ["寛元01(1243).11.03T+00", ["没"]],
111
+ ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
112
+ ["寛元01(1243).11.05T+00", []],
113
+
114
+ ["弘安04(1281).07=30T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
115
+ ["弘安04(1281).08.01T+00", []],
116
+ ["弘安04(1281).08.02T+00", ["没"]],
117
+
118
+ ["永享02(1430).07.11T+00", []],
119
+ ["永享02(1430).07.12T+00", []],
120
+ ["永享02(1430).07.13T+00", ["大夫節"]],
121
+ ["永享02(1430).07.14T+00", []],
122
+ ["永享02(1430).07.15T+00", ["白露降"]],
123
+ ["永享02(1430).07.16T+00", []],
124
+ ["永享02(1430).07.17T+00", []],
125
+ ["永享02(1430).07.18T+00", ["往亡"]],
126
+ ["永享02(1430).07.19T+00", ["卿同人"]],
127
+ ["永享02(1430).07.20T+00", ["寒蟬鳴"]],
128
+ ["永享02(1430).07.21T+00", []],
129
+ ["永享02(1430).07.22T+00", []],
130
+ ["永享02(1430).07.23T+00", []],
131
+ ["永享02(1430).07.24T+00", []],
132
+ ["永享02(1430).07.25T+00", ["没"]],
133
+
134
+ ["元和03(1617).03.18T+00", ["没"]],
135
+ ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革"]],
136
+ ["元和03(1617).03.20T+00", []],
137
+
138
+ ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
139
+ ["平成06(1994).06.22T+09:00", []]
140
+ ]
141
+ ]
142
+
143
+ 2.times do
144
+ result = []
145
+ [2039054..2039056,
146
+ 2107233..2107235,
147
+ 2160437..2160440,
148
+ 2175412..2175414,
149
+ 2189200..2189202,
150
+ 2243577..2243591,
151
+ 2311770..2311772,
152
+ 2449525..2449526].each do |range|
153
+ range.each do |jdn|
154
+ (When.when?(jdn) ^ When.CalendarEra('Japanese')).each do |date|
155
+ dates = When.CalendarNote('Japanese').send(:_to_date_for_note, date)
156
+ date = When.when?(dates.o_date.to_cal_date.to_s,
157
+ {:clock=>dates.s_date.frame.time_basis})
158
+ long = dates.cal4note.s_terms.position(date)
159
+ notes = date.notes(:indices => When::DAY,
160
+ :notes => Masks,
161
+ :locale => 'ja').simplify[:value].compact
162
+ result << [date.to_m17n/'ja', notes]
163
+ end
164
+ end
165
+ end
166
+ assert_equal(sample.shift, result)
167
+ When::CalendarNote::Japanese::SolarTerms.send(:patch=, {})
168
+ end
169
+ When::CalendarNote::Japanese::SolarTerms.send(:patch=, nil)
170
+
171
+ assert_equal('白露(135.375/560)',
172
+ When.when?('康和1.8.14').notes(:notes=>'廿四節気', :shoyo=>true)[:value].simplify.to_s)
173
+
174
+ end
175
+
176
+ def test__lunar_phases
177
+ [%w(康和3.01.09 康和3.01.16 康和3.01.23),
178
+ %w(康和3.02.08 康和3.02.16 康和3.02.23),
179
+ %w(康和3.03.08 康和3.03.15 康和3.03.22),
180
+ %w(康和3.04.09 康和3.04.16 康和3.04.23),
181
+ %w(康和3.05.08 康和3.05.15 康和3.05.22),
182
+ %w(康和3.06.08 康和3.06.15 康和3.06.23),
183
+ %w(康和3.07.08 康和3.07.15 康和3.07.22),
184
+ %w(康和3.08.07 康和3.08.14 康和3.08.22),
185
+ %w(康和3.09.07 康和3.09.15 康和3.09.23),
186
+ %w(康和3.10.08 康和3.10.15 康和3.10.23),
187
+ %w(康和3.11.07 康和3.11.15 康和3.11.23),
188
+ %w(康和3.12.08 康和3.12.16 康和3.12.23),
189
+
190
+ %w(平成26.01.01 平成26.01.08 平成26.01.16 平成26.01.24),
191
+ %w(平成26.01.31 平成26.02.07 平成26.02.15 平成26.02.23),
192
+ %w(平成26.03.01 平成26.03.08 平成26.03.17 平成26.03.24),
193
+ %w(平成26.03.31 平成26.04.07 平成26.04.15 平成26.04.22),
194
+ %w(平成26.04.29 平成26.05.07 平成26.05.15 平成26.05.21),
195
+ %w(平成26.05.29 平成26.06.06 平成26.06.13 平成26.06.20),
196
+ %w(平成26.06.27 平成26.07.05 平成26.07.12 平成26.07.19),
197
+ %w(平成26.07.27 平成26.08.04 平成26.08.11 平成26.08.17),
198
+ %w(平成26.08.25 平成26.09.02 平成26.09.09 平成26.09.16),
199
+ %w(平成26.09.24 平成26.10.02 平成26.10.08 平成26.10.16),
200
+ %w(平成26.10.24 平成26.10.31 平成26.11.07 平成26.11.15),
201
+ %w(平成26.11.22 平成26.11.29 平成26.12.06 平成26.12.14),
202
+ %w(平成26.12.22 平成26.12.29)
203
+ ].each do |month|
204
+ assert_equal([true], month.map {|date| When.when?(date).is?('月相')}.uniq)
205
+ end
206
+ end
207
+
208
+ def test__eclipse
209
+ date = When.when?('貞観4.2.1')
210
+ assert_equal('夜日蝕七分', date.notes({:notes=>'日食'}).value)
211
+ assert_nil(date.notes({:notes=>'日食', :solar_eclipse=>1}).value)
212
+
213
+ date = When.when?('貞観4.2.15')
214
+ assert_equal('(月蝕ニ分)', date.notes({:notes=>'月食'}).value)
215
+ assert_nil(date.notes({:notes=>'月食', :lunar_eclipse=>3}).value)
216
+ end
217
+
218
+ def test_japanese_lunisolar
219
+ assert_equal({1850=>{"hI"=>"Hi"}, 1866=>{"cD"=>"Cd"}, 1884=>{"cD"=>"Cd"}, 1947=>{"b"=>"c"}},
220
+ When.Calendar('Japanese').verify(When.Calendar('JapaneseTwin::旧暦'), 1844..2033))
221
+ end
222
+
223
+ def test_japanese_era
224
+ assert_raises(RangeError) {When.TemporalPosition("正慶", 2, 11)}
225
+ assert_equal("延元02(1337).01.08", When.when?("建武4.1.8").to_s)
226
+ assert_equal("延元02(1337).01.08", When.TemporalPosition("建武", 4, 1, 8, {:invalid=>:non}).to_s)
227
+ assert_equal("<神武>03(-657).01.30", When.when?('神武3.1.30').to_s) # , {'period'=>/清/})
228
+ assert_equal("日本::皇紀2600(1940).01.30", When.when?('皇紀2600.1.30').to_s) # , {'period'=>/清/})
229
+ assert_equal("応永11(1404).12.10", When.when?('嘉慶18.12.10').to_s)
230
+ assert_equal("明治01(1868).09.08", When.when?('明治1(1868).09.08').to_s)
231
+ assert_equal("天保03(0564).10.01", When.when?('天保3.10.01', {'period'=>/梁/}).to_s)
232
+ assert_equal(%w(元暦 文治 建久 正治 建仁 元久 建永 承元 建暦 建保
233
+ 承久 貞応 元仁 嘉禄 安貞 寛喜 貞永 天福 文暦 嘉禎
234
+ 暦仁 延応 仁治 寛元 宝治 建長 康元 正嘉 正元 文応
235
+ 弘長 文永 建治 弘安 正応 永仁 正安 乾元 嘉元 徳治
236
+ 延慶 応長 正和 文保 元応 元亨 正中 嘉暦 元徳 元弘),
237
+ When.era('鎌倉時代')[0].map { |era| era.label.to_s})
238
+
239
+ date = When.when?('768-10-20^^Gregorian')
240
+ assert_equal('神護景雲02(0768).09.02', (date ^ When.CalendarEra('Japanese'))[0].to_s)
241
+ assert_equal('日本?V=0764::奈良時代::神護景雲02(0768).09.01', (date ^ When.CalendarEra('Japanese?V=0764'))[0].to_s)
242
+ assert_equal('日本::奈良時代::神護景雲02(0768).09.02', (date ^ When.CalendarEra('Japanese'))[0].to_s)
243
+ end
244
+
245
+ def test__japanese_parser
246
+ assert_equal('1945-08-15', When.when?('1945 Aug 15', :parse=>'%Y %B %d').to_s)
247
+ assert_equal('2022-01-06T09:18:24+09:00', When.when?('Thu Jan 6 9:18:24 JST', {:abbr=>2015, :parse=>'%A %B %d %H:%M:%S %z'}).to_s)
248
+ assert_equal('2022-01-06T09:18:24+09:00', When.when?('木 1月 6 9:18:24 JST', {:abbr=>2015, :parse=>['%A %B %d %H:%M:%S %z', 'ja']}).to_s)
249
+ assert_equal('昭和15(1940).11.20', When.when?('昭和十五年十一月廿日', {:parse=>When::Locale::JapaneseParser}).to_s)
250
+ assert_equal('昭和59(1984).11.26', When.when?('昭和甲子年11月甲子', {:parse=>When::Locale::JapaneseParser}).to_s)
251
+ assert_equal('昭和59(1984).11.26', When.when?('昭和甲子歳11月甲子', {:parse=>When::Locale::JapaneseParser}).to_s)
252
+ assert_equal('明治01(1868).04=07T12:06:03+09:00', When.when?('明治元年閏4月甲寅12時6分3秒+09:00',
253
+ {:parse=>When::Locale::JapaneseParser}).to_s)
254
+ end
255
+
256
+ def test__japanese_digits
257
+ When::Locale::NumRExp3
258
+ assert_equal([512100060, 1200000000, 230000000, 34000000, 4500000, 560000, 67000, 7800, 890, 90, 0],
259
+ %w(伍億仟弐佰拾萬陸拾 十二億 二億三千万 三千四百万 四百五十万 五十六万 六万七千 七千八百 八百九十 九十零 零).map {|fig|
260
+ When::Locale.k2a_digits(fig, true)
261
+ })
262
+ end
263
+
264
+ =begin
265
+ def test_japanese_date
266
+ jc = When.Resource('_c:Japanese')
267
+ diff = []
268
+ open('test/region/japanese-calendar.txt', "1".respond_to?(:force_encoding) ? 'r:utf-8' : 'r') do |f|
269
+ while (line = f.gets)
270
+ next if line =~ /\A *#/
271
+ x, x, jdn, x, x, x, gy, gm, gd, x, x, jy, jm, jd = line.split(/ +/).map {|v| v.to_i}
272
+ jm, leap = (jm > 0) ? [jm, '-'] : [-jm, '=']
273
+ date = When.when?("%04d-%02d%s%02d" % [(gm >= jm) ? gy : gy-1, jm, leap, jd], {:frame=>jc})
274
+ diff << [jdn - date.to_i, date.to_s] unless jdn == date.to_i
275
+ end
276
+ end
277
+ assert_equal([], diff)
278
+ end
279
+ =end
280
+ end
281
+ end