when_exe 0.3.6 → 0.3.7

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 (117) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +171 -0
  3. data/lib/when_exe.rb +78 -47
  4. data/lib/when_exe/basictypes.rb +752 -747
  5. data/lib/when_exe/calendarnote.rb +805 -801
  6. data/lib/when_exe/calendartypes.rb +1583 -1531
  7. data/lib/when_exe/coordinates.rb +16 -15
  8. data/lib/when_exe/core/duration.rb +114 -110
  9. data/lib/when_exe/core/extension.rb +504 -504
  10. data/lib/when_exe/ephemeris.rb +1917 -1913
  11. data/lib/when_exe/ephemeris/moon.rb +333 -333
  12. data/lib/when_exe/ephemeris/notes.rb +389 -387
  13. data/lib/when_exe/ephemeris/planets.rb +585 -585
  14. data/lib/when_exe/ephemeris/sun.rb +214 -214
  15. data/lib/when_exe/googlecalendar.rb +144 -140
  16. data/lib/when_exe/icalendar.rb +1636 -1636
  17. data/lib/when_exe/inspect.rb +46 -22
  18. data/lib/when_exe/locales/akt.rb +176 -176
  19. data/lib/when_exe/locales/encoding_conversion.rb +134 -126
  20. data/lib/when_exe/locales/iast.rb +90 -90
  21. data/lib/when_exe/locales/locale.rb +750 -746
  22. data/lib/when_exe/locales/transliteration_table.rb +62 -62
  23. data/lib/when_exe/mini_application.rb +307 -305
  24. data/lib/when_exe/parts/enumerator.rb +2 -2
  25. data/lib/when_exe/parts/geometric_complex.rb +397 -397
  26. data/lib/when_exe/parts/method_cash.rb +224 -224
  27. data/lib/when_exe/parts/resource.rb +1069 -1071
  28. data/lib/when_exe/parts/timezone.rb +240 -230
  29. data/lib/when_exe/region/armenian.rb +56 -56
  30. data/lib/when_exe/region/babylonian.rb +405 -0
  31. data/lib/when_exe/region/bahai.rb +146 -146
  32. data/lib/when_exe/region/balinese.rb +622 -622
  33. data/lib/when_exe/region/chinese.rb +95 -25
  34. data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
  35. data/lib/when_exe/region/chinese/epochs.rb +1 -1
  36. data/lib/when_exe/region/chinese/twins.rb +803 -795
  37. data/lib/when_exe/region/christian.rb +824 -824
  38. data/lib/when_exe/region/coptic.rb +106 -87
  39. data/lib/when_exe/region/discordian.rb +225 -225
  40. data/lib/when_exe/region/far_east.rb +188 -188
  41. data/lib/when_exe/region/french.rb +56 -56
  42. data/lib/when_exe/region/geologicalage.rb +639 -639
  43. data/lib/when_exe/region/goddess.rb +58 -58
  44. data/lib/when_exe/region/indian.rb +1254 -1251
  45. data/lib/when_exe/region/iranian.rb +8 -8
  46. data/lib/when_exe/region/islamic.rb +3 -3
  47. data/lib/when_exe/region/japanese.rb +93 -99
  48. data/lib/when_exe/region/japanese/calendars.rb +396 -397
  49. data/lib/when_exe/region/japanese/epochs.rb +26 -26
  50. data/lib/when_exe/region/japanese/nihon_shoki.rb +71 -71
  51. data/lib/when_exe/region/japanese/notes.rb +1383 -1386
  52. data/lib/when_exe/region/japanese/residues.rb +1306 -1306
  53. data/lib/when_exe/region/japanese/twins.rb +225 -225
  54. data/lib/when_exe/region/japanese/weeks.rb +112 -0
  55. data/lib/when_exe/region/javanese.rb +230 -230
  56. data/lib/when_exe/region/jewish.rb +126 -126
  57. data/lib/when_exe/region/korean.rb +378 -378
  58. data/lib/when_exe/region/m17n.rb +114 -113
  59. data/lib/when_exe/region/martian.rb +258 -255
  60. data/lib/when_exe/region/mayan.rb +32 -32
  61. data/lib/when_exe/region/residue.rb +89 -89
  62. data/lib/when_exe/region/roman.rb +36 -24
  63. data/lib/when_exe/region/ryukyu.rb +97 -97
  64. data/lib/when_exe/region/shire.rb +240 -240
  65. data/lib/when_exe/region/soviet.rb +209 -0
  66. data/lib/when_exe/region/symmetry.rb +50 -50
  67. data/lib/when_exe/region/thai.rb +336 -335
  68. data/lib/when_exe/region/tibetan.rb +316 -315
  69. data/lib/when_exe/region/vietnamese.rb +440 -439
  70. data/lib/when_exe/region/weekdate.rb +80 -80
  71. data/lib/when_exe/region/world.rb +175 -175
  72. data/lib/when_exe/region/yerm.rb +14 -14
  73. data/lib/when_exe/region/zoroastrian.rb +203 -203
  74. data/lib/when_exe/timestandard.rb +707 -681
  75. data/lib/when_exe/tmduration.rb +338 -330
  76. data/lib/when_exe/tmobjects.rb +1346 -1325
  77. data/lib/when_exe/tmposition.rb +2115 -2072
  78. data/lib/when_exe/tmreference.rb +1693 -1669
  79. data/lib/when_exe/version.rb +1 -1
  80. data/link_to_online_documents +1 -1
  81. data/test/examples/JapanHolidaysRFC6350.ics +1 -1
  82. data/test/test.rb +67 -61
  83. data/test/test/basictypes.rb +409 -409
  84. data/test/test/calendarnote.rb +86 -69
  85. data/test/test/calendartypes.rb +97 -97
  86. data/test/test/coordinates.rb +396 -396
  87. data/test/test/ephemeris.rb +83 -74
  88. data/test/test/ephemeris/moon.rb +14 -14
  89. data/test/test/ephemeris/planets.rb +14 -14
  90. data/test/test/ephemeris/sun.rb +14 -14
  91. data/test/test/googlecalendar.rb +194 -176
  92. data/test/test/icalendar.rb +867 -858
  93. data/test/test/inspect.rb +117 -117
  94. data/test/test/parts.rb +487 -487
  95. data/test/test/region/balinese.rb +34 -0
  96. data/test/test/region/chinese.rb +218 -206
  97. data/test/test/region/christian.rb +245 -245
  98. data/test/test/region/coptic.rb +27 -27
  99. data/test/test/region/french.rb +33 -33
  100. data/test/test/region/geologicalage.rb +17 -17
  101. data/test/test/region/indian.rb +57 -57
  102. data/test/test/region/iran.rb +54 -54
  103. data/test/test/region/islamic.rb +18 -18
  104. data/test/test/region/japanese.rb +237 -219
  105. data/test/test/region/jewish.rb +61 -61
  106. data/test/test/region/m17n.rb +184 -184
  107. data/test/test/region/mayan.rb +195 -195
  108. data/test/test/region/residue.rb +147 -139
  109. data/test/test/region/thai.rb +116 -116
  110. data/test/test/region/tibetan.rb +30 -30
  111. data/test/test/region/vietnamese.rb +102 -102
  112. data/test/test/region/yerm.rb +146 -146
  113. data/test/test/timestandard.rb +81 -81
  114. data/test/test/tmobjects.rb +328 -328
  115. data/test/test/tmposition.rb +397 -284
  116. data/test/test/tmreference.rb +157 -157
  117. metadata +13 -10
@@ -1,27 +1,27 @@
1
- # -*- coding: utf-8 -*-
2
- =begin
3
- Copyright (C) 2014 Takashi SUGA
4
-
5
- You may use and/or modify this file according to the license
6
- described in the LICENSE.txt file included in this archive.
7
- =end
8
-
9
- module Test
10
-
11
- class Coptic < Test::Unit::TestCase
12
- def test__coptic
13
- julian = When.Calendar('Julian')
14
- gregorian = When.Calendar('Gregorian')
15
- ethiopian = When.Calendar('Coptic?Epoch=8Y')
16
- egyptian = When.Calendar('Coptic?Epoch=284Y')
17
-
18
- [['2010-8-29', %w(2010-08-29 2010-09-11 2003-01-01 1727-01-01)],
19
- ['2011-8-30', %w(2011-08-30 2011-09-12 2004-01-01 1728-01-01)],
20
- ['2012-8-29', %w(2012-08-29 2012-09-11 2005-01-01 1729-01-01)],
21
- ['2013-8-29', %w(2013-08-29 2013-09-11 2006-01-01 1730-01-01)]].each do |sample|
22
- date = When.when?(sample[0], :frame=>julian)
23
- assert_equal(sample[1], [date.to_s, (gregorian ^ date).to_s, (ethiopian ^ date).to_s, (egyptian ^ date).to_s])
24
- end
25
- end
26
- end
27
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2014 Takashi SUGA
4
+
5
+ You may use and/or modify this file according to the license
6
+ described in the LICENSE.txt file included in this archive.
7
+ =end
8
+
9
+ module MiniTest
10
+
11
+ class Coptic < MiniTest::TestCase
12
+ def test__coptic
13
+ julian = When.Calendar('Julian')
14
+ gregorian = When.Calendar('Gregorian')
15
+ ethiopian = When.Calendar('Coptic?Epoch=8Y')
16
+ egyptian = When.Calendar('Coptic?Epoch=284Y')
17
+
18
+ [['2010-8-29', %w(2010-08-29 2010-09-11 2003-01-01 1727-01-01)],
19
+ ['2011-8-30', %w(2011-08-30 2011-09-12 2004-01-01 1728-01-01)],
20
+ ['2012-8-29', %w(2012-08-29 2012-09-11 2005-01-01 1729-01-01)],
21
+ ['2013-8-29', %w(2013-08-29 2013-09-11 2006-01-01 1730-01-01)]].each do |sample|
22
+ date = When.when?(sample[0], :frame=>julian)
23
+ assert_equal(sample[1], [date.to_s, (gregorian ^ date).to_s, (ethiopian ^ date).to_s, (egyptian ^ date).to_s])
24
+ end
25
+ end
26
+ end
27
+ end
@@ -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 Test
10
-
11
- class FrenchRepublican < Test::Unit::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 Test::TM
10
- class GeologicalAge < Test::Unit::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-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,57 +1,57 @@
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 Test
10
-
11
- class Indian < Test::Unit::TestCase
12
- Sample1 = [
13
- "1913-03-01-", "1913-03-02-", "1913-03-03-", "1913-03-04-", "1913-03-05%", "1913-03-07-", "1913-03-08-", "1913-03-09-",
14
- "1913-03-10-", "1913-03-11-", "1913-03-12-", "1913-03-13-", "1913-03-14-", "1913-03-15-", "1913-03-15=", "1913-03<01-",
15
- "1913-03<02-", "1913-03<03-", "1913-03<04-", "1913-03<05-", "1913-03<06-", "1913-03<07-", "1913-03<08-", "1913-03<09-",
16
- "1913-03<10-", "1913-03<11-", "1913-03<12-", "1913-03<13%", "1913-03<15-", "1913-04-01-", "1913-04-02-", "1913-04-03-",
17
- "1913-04-04-", "1913-04-05-", "1913-04-06-", "1913-04-07-", "1913-04-08-", "1913-04-09-", "1913-04-10-", "1913-04-11-",
18
- "1913-04-12-", "1913-04-13-", "1913-04-14-", "1913-04-15-", "1913-04<01-", "1913-04<02-", "1913-04<03-", "1913-04<04-",
19
- "1913-04<05-", "1913-04<06-", "1913-04<07-", "1913-04<08-", "1913-04<09-", "1913-04<10-", "1913-04<11-", "1913-04<12-",
20
- "1913-04<13-", "1913-04<14-", "1913-04<15%", "1913-05-02-"
21
- ]
22
-
23
- Sample2 = [
24
- "1913-04-01-", "1913-04-02-", "1913-04-03-", "1913-04-04-", "1913-04-05%", "1913-04-07-", "1913-04-08-", "1913-04-09-"
25
- ]
26
-
27
- def test_indian_date_1
28
- cc = When.Calendar('HinduLuniSolar')
29
- date = When.when?('1913-03-01', {:frame=>cc})
30
- assert_equal("Jyaiṣṭha Śuklapakṣa", date.name('month').to_s)
31
- start = 2448421
32
- Sample1.size.times do |i|
33
- assert_equal([Sample1[i], start+i], [date.to_s, date.to_i])
34
- date += When.Duration('P1D')
35
- end
36
- end
37
-
38
- def test_indian_date_2
39
- cc = When.Calendar('HinduLuniSolar?start_month=4')
40
- date = When.when?('1913-04-01', {:frame=>cc})
41
- assert_equal("Jyaiṣṭha Śuklapakṣa", date.name('month').to_s)
42
- start = 2448421
43
- Sample2.size.times do |i|
44
- assert_equal([Sample2[i], start+i], [date.to_s, date.to_i])
45
- date += When.Duration('P1D')
46
- end
47
- end
48
-
49
- def test_indian_date_3
50
- cc = When.Calendar('HinduSolar?type=SBS')
51
- date = When.when?('1913-01-01', {:frame=>cc})
52
- assert_equal([2448361, "1913-01-01", "1991-04-14"], [date.to_i, date.to_s, date.to_date.to_s])
53
- date = When::CalendarNote::HinduNote::Dates.new(date)
54
- assert_equal(2448361, date.to_i)
55
- end
56
- end
57
- end
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 Indian < MiniTest::TestCase
12
+ Sample1 = [
13
+ "1913-03-01-", "1913-03-02-", "1913-03-03-", "1913-03-04-", "1913-03-05%", "1913-03-07-", "1913-03-08-", "1913-03-09-",
14
+ "1913-03-10-", "1913-03-11-", "1913-03-12-", "1913-03-13-", "1913-03-14-", "1913-03-15-", "1913-03-15=", "1913-03<01-",
15
+ "1913-03<02-", "1913-03<03-", "1913-03<04-", "1913-03<05-", "1913-03<06-", "1913-03<07-", "1913-03<08-", "1913-03<09-",
16
+ "1913-03<10-", "1913-03<11-", "1913-03<12-", "1913-03<13%", "1913-03<15-", "1913-04-01-", "1913-04-02-", "1913-04-03-",
17
+ "1913-04-04-", "1913-04-05-", "1913-04-06-", "1913-04-07-", "1913-04-08-", "1913-04-09-", "1913-04-10-", "1913-04-11-",
18
+ "1913-04-12-", "1913-04-13-", "1913-04-14-", "1913-04-15-", "1913-04<01-", "1913-04<02-", "1913-04<03-", "1913-04<04-",
19
+ "1913-04<05-", "1913-04<06-", "1913-04<07-", "1913-04<08-", "1913-04<09-", "1913-04<10-", "1913-04<11-", "1913-04<12-",
20
+ "1913-04<13-", "1913-04<14-", "1913-04<15%", "1913-05-02-"
21
+ ]
22
+
23
+ Sample2 = [
24
+ "1913-04-01-", "1913-04-02-", "1913-04-03-", "1913-04-04-", "1913-04-05%", "1913-04-07-", "1913-04-08-", "1913-04-09-"
25
+ ]
26
+
27
+ def test_indian_date_1
28
+ cc = When.Calendar('HinduLuniSolar')
29
+ date = When.when?('1913-03-01', {:frame=>cc})
30
+ assert_equal("Jyaiṣṭha Śuklapakṣa", date.name('month').to_s)
31
+ start = 2448421
32
+ Sample1.size.times do |i|
33
+ assert_equal([Sample1[i], start+i], [date.to_s, date.to_i])
34
+ date += When.Duration('P1D')
35
+ end
36
+ end
37
+
38
+ def test_indian_date_2
39
+ cc = When.Calendar('HinduLuniSolar?start_month=4')
40
+ date = When.when?('1913-04-01', {:frame=>cc})
41
+ assert_equal("Jyaiṣṭha Śuklapakṣa", date.name('month').to_s)
42
+ start = 2448421
43
+ Sample2.size.times do |i|
44
+ assert_equal([Sample2[i], start+i], [date.to_s, date.to_i])
45
+ date += When.Duration('P1D')
46
+ end
47
+ end
48
+
49
+ def test_indian_date_3
50
+ cc = When.Calendar('HinduSolar?type=SBS')
51
+ date = When.when?('1913-01-01', {:frame=>cc})
52
+ assert_equal([2448361, "1913-01-01", "1991-04-14"], [date.to_i, date.to_s, date.to_date.to_s])
53
+ date = When::CalendarNote::HinduNote::Dates.new(date)
54
+ assert_equal(2448361, date.to_i)
55
+ end
56
+ end
57
+ 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 Test
10
-
11
- class Iranian < Test::Unit::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,18 +1,18 @@
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 Test
10
-
11
- module CalendarTypes
12
- class Islamic < Test::Unit::TestCase
13
- def test_nothing
14
- end
15
- end
16
- end
17
-
18
- end
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
+ module CalendarTypes
12
+ class Islamic < MiniTest::TestCase
13
+ def test_nothing
14
+ end
15
+ end
16
+ end
17
+
18
+ end
@@ -1,219 +1,237 @@
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 Test
10
-
11
- class Japanese < Test::Unit::TestCase
12
-
13
- include When::CalendarNote::Japanese::Index
14
-
15
- def test_japanese_epoch
16
- eras = When.Resource('_e:Japanese')
17
-
18
- sample =
19
- [["天平21(0749).04.13", "天平感宝01(0749).04.13", "天平勝宝01(0749).04.13"],
20
- ["天平21(0749).04.13"],
21
- ["天平感宝01(0749).04.14", "天平勝宝01(0749).04.14"],
22
- ["天平感宝01(0749).04.14"],
23
- ["天平勝宝01(0749).07.02"],
24
- ["天平勝宝01(0749).07.02"]]
25
- ['天平勝宝01.04.13', '天平勝宝01.04.14', '天平勝宝01.07.02'].each do |string|
26
- assert_equal(sample.shift, ((When.when?(string) ^ eras).
27
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
28
- assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
29
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
30
- end
31
-
32
- sample =
33
- [["大正15(1926).12.24"],
34
- ["大正15(1926).12.24"],
35
- ["昭和01(1926).12.25"],
36
- ["昭和01(1926).12.25"],
37
- ["昭和01(1926).12.26"],
38
- ["昭和01(1926).12.26"]]
39
- ['大正15.12.24', '大正15.12.25', '大正15.12.26'].each do |string|
40
- assert_equal(sample.shift, ((When.when?(string) ^ eras).
41
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
42
- assert_equal(sample.shift, ((When.when?(string, {:lower=>true}) ^ eras).
43
- delete_if {|d| !d.leaf?}).map {|d| d.to_s})
44
- end
45
- end
46
-
47
- def test__solar_terms
48
- sample = [
49
- [ # 修正後
50
- ["貞観12(0870).07.17T+00", []],
51
- ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損", "没"]],
52
- ["貞観12(0870).07.19T+00", []],
53
-
54
- ["天喜05(1057).03.10T+00", []],
55
- ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
56
- ["天喜05(1057).03.12T+00", []],
57
-
58
- ["建仁02(1202).10=29T+00", ["没"]],
59
- ["建仁02(1202).11.01T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
60
- ["建仁02(1202).11.02T+00", []],
61
- ["建仁02(1202).11.03T+00", []],
62
-
63
- ["寛元01(1243).11.03T+00", []],
64
- ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚", "没"]],
65
- ["寛元01(1243).11.05T+00", []],
66
-
67
- ["弘安04(1281).07=30T+00", ["没"]],
68
- ["弘安04(1281).08.01T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
69
- ["弘安04(1281).08.02T+00", []],
70
-
71
- ["永享02(1430).07.11T+00", ["没"]],
72
- ["永享02(1430).07.12T+00", []],
73
- ["永享02(1430).07.13T+00", []],
74
- ["永享02(1430).07.14T+00", ["大夫節"]],
75
- ["永享02(1430).07.15T+00", []],
76
- ["永享02(1430).07.16T+00", ["白露降"]],
77
- ["永享02(1430).07.17T+00", []],
78
- ["永享02(1430).07.18T+00", []],
79
- ["永享02(1430).07.19T+00", ["往亡"]],
80
- ["永享02(1430).07.20T+00", ["卿同人"]],
81
- ["永享02(1430).07.21T+00", ["寒蟬鳴"]],
82
- ["永享02(1430).07.22T+00", []],
83
- ["永享02(1430).07.23T+00", []],
84
- ["永享02(1430).07.24T+00", []],
85
- ["永享02(1430).07.25T+00", []],
86
-
87
- ["元和03(1617).03.18T+00", []],
88
- ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革", "没"]],
89
- ["元和03(1617).03.20T+00", []],
90
-
91
- ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
92
- ["平成06(1994).06.22T+09:00", []]
93
- ],
94
-
95
- [ # 修正前
96
- ["貞観12(0870).07.17T+00", ["没"]],
97
- ["貞観12(0870).07.18T+00", ["処暑(150)", "鷹乃祭鳥", "公損"]],
98
- ["貞観12(0870).07.19T+00", []],
99
-
100
- ["天喜05(1057).03.10T+00", ["没"]],
101
- ["天喜05(1057).03.11T+00", ["穀雨(30)", "萍始生", "公革"]],
102
- ["天喜05(1057).03.12T+00", []],
103
-
104
- ["建仁02(1202).10=29T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
105
- ["建仁02(1202).11.01T+00", []],
106
- ["建仁02(1202).11.02T+00", []],
107
- ["建仁02(1202).11.03T+00", ["没"]],
108
-
109
- ["寛元01(1243).11.03T+00", ["没"]],
110
- ["寛元01(1243).11.04T+00", ["冬至(270)", "蚯蚓結", "公中孚"]],
111
- ["寛元01(1243).11.05T+00", []],
112
-
113
- ["弘安04(1281).07=30T+00", ["秋分(180)", "雷乃收聲", "公賁"]],
114
- ["弘安04(1281).08.01T+00", []],
115
- ["弘安04(1281).08.02T+00", ["没"]],
116
-
117
- ["永享02(1430).07.11T+00", []],
118
- ["永享02(1430).07.12T+00", []],
119
- ["永享02(1430).07.13T+00", ["大夫節"]],
120
- ["永享02(1430).07.14T+00", []],
121
- ["永享02(1430).07.15T+00", ["白露降"]],
122
- ["永享02(1430).07.16T+00", []],
123
- ["永享02(1430).07.17T+00", []],
124
- ["永享02(1430).07.18T+00", ["往亡"]],
125
- ["永享02(1430).07.19T+00", ["卿同人"]],
126
- ["永享02(1430).07.20T+00", ["寒蟬鳴"]],
127
- ["永享02(1430).07.21T+00", []],
128
- ["永享02(1430).07.22T+00", []],
129
- ["永享02(1430).07.23T+00", []],
130
- ["永享02(1430).07.24T+00", []],
131
- ["永享02(1430).07.25T+00", ["没"]],
132
-
133
- ["元和03(1617).03.18T+00", ["没"]],
134
- ["元和03(1617).03.19T+00", ["穀雨(30)", "萍始生", "公革"]],
135
- ["元和03(1617).03.20T+00", []],
136
-
137
- ["平成06(1994).06.21T+09:00", ["夏至(90)", "乃東枯"]],
138
- ["平成06(1994).06.22T+09:00", []]
139
- ]
140
- ]
141
-
142
- 2.times do
143
- result = []
144
- [2039054..2039056,
145
- 2107233..2107235,
146
- 2160437..2160440,
147
- 2175412..2175414,
148
- 2189200..2189202,
149
- 2243577..2243591,
150
- 2311770..2311772,
151
- 2449525..2449526].each do |range|
152
- range.each do |jdn|
153
- (When.when?(jdn) ^ When.CalendarEra('Japanese')).each do |date|
154
- dates = When.CalendarNote('Japanese').send(:_to_date_for_note, date)
155
- date = When.when?(dates.o_date.to_cal_date.to_s,
156
- {:clock=>dates.s_date.frame.time_basis})
157
- long = dates.cal4note.s_terms.position(date)
158
- notes = date.notes(:indices => When::DAY,
159
- :notes => MD廿四節気|MD七十二候|MD六十卦|MD没|MD往亡,
160
- :locale => 'ja').simplify[:value].compact
161
- result << [date.to_m17n/'ja', notes]
162
- end
163
- end
164
- end
165
- assert_equal(sample.shift, result)
166
- When::CalendarNote::Japanese::SolarTerms.send(:patch=, {})
167
- end
168
- When::CalendarNote::Japanese::SolarTerms.send(:patch=, nil)
169
- end
170
-
171
- def test__lunar_phases
172
- [%w(康和3.01.09 康和3.01.16 康和3.01.23),
173
- %w(康和3.02.08 康和3.02.16 康和3.02.23),
174
- %w(康和3.03.08 康和3.03.15 康和3.03.22),
175
- %w(康和3.04.09 康和3.04.16 康和3.04.23),
176
- %w(康和3.05.08 康和3.05.15 康和3.05.22),
177
- %w(康和3.06.08 康和3.06.15 康和3.06.23),
178
- %w(康和3.07.08 康和3.07.15 康和3.07.22),
179
- %w(康和3.08.07 康和3.08.14 康和3.08.22),
180
- %w(康和3.09.07 康和3.09.15 康和3.09.23),
181
- %w(康和3.10.08 康和3.10.15 康和3.10.23),
182
- %w(康和3.11.07 康和3.11.15 康和3.11.23),
183
- %w(康和3.12.08 康和3.12.16 康和3.12.23),
184
-
185
- %w(平成26.01.01 平成26.01.08 平成26.01.16 平成26.01.24),
186
- %w(平成26.01.31 平成26.02.07 平成26.02.15 平成26.02.23),
187
- %w(平成26.03.01 平成26.03.08 平成26.03.17 平成26.03.24),
188
- %w(平成26.03.31 平成26.04.07 平成26.04.15 平成26.04.22),
189
- %w(平成26.04.29 平成26.05.07 平成26.05.15 平成26.05.21),
190
- %w(平成26.05.29 平成26.06.06 平成26.06.13 平成26.06.20),
191
- %w(平成26.06.27 平成26.07.05 平成26.07.12 平成26.07.19),
192
- %w(平成26.07.27 平成26.08.04 平成26.08.11 平成26.08.17),
193
- %w(平成26.08.25 平成26.09.02 平成26.09.09 平成26.09.16),
194
- %w(平成26.09.24 平成26.10.02 平成26.10.08 平成26.10.16),
195
- %w(平成26.10.24 平成26.10.31 平成26.11.07 平成26.11.15),
196
- %w(平成26.11.22 平成26.11.29 平成26.12.06 平成26.12.14),
197
- %w(平成26.12.22 平成26.12.29)
198
- ].each do |month|
199
- assert_equal([true], month.map {|date| When.when?(date).is?('月相')}.uniq)
200
- end
201
- end
202
- =begin
203
- def test_japanese_date
204
- jc = When.Resource('_c:Japanese')
205
- diff = []
206
- open('test/region/japanese-calendar.txt', "1".respond_to?(:force_encoding) ? 'r:utf-8' : 'r') do |f|
207
- while (line = f.gets)
208
- next if line =~ /^ *#/
209
- x, x, jdn, x, x, x, gy, gm, gd, x, x, jy, jm, jd = line.split(/ +/).map {|v| v.to_i}
210
- jm, leap = (jm > 0) ? [jm, '-'] : [-jm, '=']
211
- date = When.when?("%04d-%02d%s%02d" % [(gm >= jm) ? gy : gy-1, jm, leap, jd], {:frame=>jc})
212
- diff << [jdn - date.to_i, date.to_s] unless jdn == date.to_i
213
- end
214
- end
215
- assert_equal([], diff)
216
- end
217
- =end
218
- end
219
- 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 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
+ end
171
+
172
+ def test__lunar_phases
173
+ [%w(康和3.01.09 康和3.01.16 康和3.01.23),
174
+ %w(康和3.02.08 康和3.02.16 康和3.02.23),
175
+ %w(康和3.03.08 康和3.03.15 康和3.03.22),
176
+ %w(康和3.04.09 康和3.04.16 康和3.04.23),
177
+ %w(康和3.05.08 康和3.05.15 康和3.05.22),
178
+ %w(康和3.06.08 康和3.06.15 康和3.06.23),
179
+ %w(康和3.07.08 康和3.07.15 康和3.07.22),
180
+ %w(康和3.08.07 康和3.08.14 康和3.08.22),
181
+ %w(康和3.09.07 康和3.09.15 康和3.09.23),
182
+ %w(康和3.10.08 康和3.10.15 康和3.10.23),
183
+ %w(康和3.11.07 康和3.11.15 康和3.11.23),
184
+ %w(康和3.12.08 康和3.12.16 康和3.12.23),
185
+
186
+ %w(平成26.01.01 平成26.01.08 平成26.01.16 平成26.01.24),
187
+ %w(平成26.01.31 平成26.02.07 平成26.02.15 平成26.02.23),
188
+ %w(平成26.03.01 平成26.03.08 平成26.03.17 平成26.03.24),
189
+ %w(平成26.03.31 平成26.04.07 平成26.04.15 平成26.04.22),
190
+ %w(平成26.04.29 平成26.05.07 平成26.05.15 平成26.05.21),
191
+ %w(平成26.05.29 平成26.06.06 平成26.06.13 平成26.06.20),
192
+ %w(平成26.06.27 平成26.07.05 平成26.07.12 平成26.07.19),
193
+ %w(平成26.07.27 平成26.08.04 平成26.08.11 平成26.08.17),
194
+ %w(平成26.08.25 平成26.09.02 平成26.09.09 平成26.09.16),
195
+ %w(平成26.09.24 平成26.10.02 平成26.10.08 平成26.10.16),
196
+ %w(平成26.10.24 平成26.10.31 平成26.11.07 平成26.11.15),
197
+ %w(平成26.11.22 平成26.11.29 平成26.12.06 平成26.12.14),
198
+ %w(平成26.12.22 平成26.12.29)
199
+ ].each do |month|
200
+ assert_equal([true], month.map {|date| When.when?(date).is?('月相')}.uniq)
201
+ end
202
+ end
203
+
204
+ def test_japanese_era
205
+ assert_raises(RangeError) {When.TemporalPosition("正慶", 2, 11)}
206
+ assert_equal("延元02(1337).01.08", When.when?("建武4.1.8").to_s)
207
+ assert_equal("延元02(1337).01.08", When.TemporalPosition("建武", 4, 1, 8, {:invalid=>:non}).to_s)
208
+ assert_equal("神武03(-657).01.30", When.when?('神武3.1.30').to_s) # , {'period'=>/清/})
209
+ assert_equal("日本::皇紀2600(1940).01.30", When.when?('皇紀2600.1.30').to_s) # , {'period'=>/清/})
210
+ assert_equal("応永11(1404).12.10", When.when?('嘉慶18.12.10').to_s)
211
+ assert_equal("明治01(1868).09.08", When.when?('明治1(1868).09.08').to_s)
212
+ assert_equal("天保03(0564).10.01", When.when?('天保3.10.01', {'period'=>/梁/}).to_s)
213
+ assert_equal(%w(元暦 文治 建久 正治 建仁 元久 建永 承元 建暦 建保
214
+ 承久 貞応 元仁 嘉禄 安貞 寛喜 貞永 天福 文暦 嘉禎
215
+ 暦仁 延応 仁治 寛元 宝治 建長 康元 正嘉 正元 文応
216
+ 弘長 文永 建治 弘安 正応 永仁 正安 乾元 嘉元 徳治
217
+ 延慶 応長 正和 文保 元応 元亨 正中 嘉暦 元徳 元弘),
218
+ When.era('鎌倉時代')[0].map { |era| era.label.to_s})
219
+ end
220
+ =begin
221
+ def test_japanese_date
222
+ jc = When.Resource('_c:Japanese')
223
+ diff = []
224
+ open('test/region/japanese-calendar.txt', "1".respond_to?(:force_encoding) ? 'r:utf-8' : 'r') do |f|
225
+ while (line = f.gets)
226
+ next if line =~ /\A *#/
227
+ x, x, jdn, x, x, x, gy, gm, gd, x, x, jy, jm, jd = line.split(/ +/).map {|v| v.to_i}
228
+ jm, leap = (jm > 0) ? [jm, '-'] : [-jm, '=']
229
+ date = When.when?("%04d-%02d%s%02d" % [(gm >= jm) ? gy : gy-1, jm, leap, jd], {:frame=>jc})
230
+ diff << [jdn - date.to_i, date.to_s] unless jdn == date.to_i
231
+ end
232
+ end
233
+ assert_equal([], diff)
234
+ end
235
+ =end
236
+ end
237
+ end