when_exe 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
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 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,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,54 @@
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-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,261 +1,261 @@
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-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