when_exe 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -33
  3. data/bin/locales.rb +1 -1
  4. data/bin/make_ttl.rb.config +1 -1
  5. data/lib/when_exe.rb +27 -16
  6. data/lib/when_exe/basictypes.rb +772 -771
  7. data/lib/when_exe/calendartypes.rb +1485 -1453
  8. data/lib/when_exe/coordinates.rb +5 -0
  9. data/lib/when_exe/core/compatibility.rb +1 -1
  10. data/lib/when_exe/core/duration.rb +147 -116
  11. data/lib/when_exe/core/extension.rb +499 -497
  12. data/lib/when_exe/ephemeris.rb +1952 -1951
  13. data/lib/when_exe/ephemeris/eclipse.rb +5 -4
  14. data/lib/when_exe/ephemeris/notes.rb +457 -421
  15. data/lib/when_exe/ephemeris/planets.rb +585 -585
  16. data/lib/when_exe/ephemeris/sun.rb +214 -214
  17. data/lib/when_exe/google_api.rb +153 -0
  18. data/lib/when_exe/icalendar.rb +1640 -1632
  19. data/lib/when_exe/inspect.rb +42 -20
  20. data/lib/when_exe/linkeddata.rb +28 -7
  21. data/lib/when_exe/locales/autoload.rb +2 -1
  22. data/lib/when_exe/locales/locale.rb +35 -15
  23. data/lib/when_exe/locales/zh.rb +77 -0
  24. data/lib/when_exe/mini_application.rb +3 -1
  25. data/lib/when_exe/{googlecalendar.rb → obsolete/googlecalendar.rb} +144 -144
  26. data/lib/when_exe/parts/enumerator.rb +498 -486
  27. data/lib/when_exe/parts/geometric_complex.rb +397 -397
  28. data/lib/when_exe/parts/timezone.rb +246 -241
  29. data/lib/when_exe/region/armenian.rb +55 -56
  30. data/lib/when_exe/region/babylonian.rb +406 -405
  31. data/lib/when_exe/region/bahai.rb +107 -106
  32. data/lib/when_exe/region/balinese.rb +624 -622
  33. data/lib/when_exe/region/chinese.rb +1071 -1026
  34. data/lib/when_exe/region/chinese/epochs.rb +28 -28
  35. data/lib/when_exe/region/chinese/notes.rb +219 -0
  36. data/lib/when_exe/region/chinese/twins.rb +803 -803
  37. data/lib/when_exe/region/christian.rb +21 -15
  38. data/lib/when_exe/region/coptic.rb +107 -106
  39. data/lib/when_exe/region/discordian.rb +218 -218
  40. data/lib/when_exe/region/east_asian.rb +1 -1
  41. data/lib/when_exe/region/french.rb +126 -56
  42. data/lib/when_exe/region/geologicalage.rb +639 -639
  43. data/lib/when_exe/region/goddess.rb +60 -58
  44. data/lib/when_exe/region/hanke_henry.rb +2 -2
  45. data/lib/when_exe/region/indian.rb +1225 -1222
  46. data/lib/when_exe/region/international_fixed.rb +96 -97
  47. data/lib/when_exe/region/iranian.rb +206 -203
  48. data/lib/when_exe/region/islamic.rb +102 -102
  49. data/lib/when_exe/region/japanese.rb +126 -71
  50. data/lib/when_exe/region/japanese/epochs.rb +426 -426
  51. data/lib/when_exe/region/japanese/notes.rb +101 -81
  52. data/lib/when_exe/region/japanese/residues.rb +1345 -1311
  53. data/lib/when_exe/region/japanese/twins.rb +225 -225
  54. data/lib/when_exe/region/japanese/weeks.rb +112 -112
  55. data/lib/when_exe/region/javanese.rb +230 -230
  56. data/lib/when_exe/region/jewish.rb +130 -131
  57. data/lib/when_exe/region/m17n.rb +114 -114
  58. data/lib/when_exe/region/martian.rb +258 -258
  59. data/lib/when_exe/region/mayan.rb +11 -8
  60. data/lib/when_exe/region/pax.rb +4 -5
  61. data/lib/when_exe/region/pope.rb +1 -1
  62. data/lib/when_exe/region/positivist.rb +100 -100
  63. data/lib/when_exe/region/residue.rb +162 -162
  64. data/lib/when_exe/region/roman.rb +333 -333
  65. data/lib/when_exe/region/{soviet.rb → russian.rb} +221 -209
  66. data/lib/when_exe/region/shire.rb +222 -223
  67. data/lib/when_exe/region/symmetry.rb +50 -50
  68. data/lib/when_exe/region/thai.rb +336 -336
  69. data/lib/when_exe/region/tibetan.rb +315 -316
  70. data/lib/when_exe/region/tranquility.rb +207 -208
  71. data/lib/when_exe/region/vanishing_leprechaun.rb +3 -1
  72. data/lib/when_exe/region/vietnamese.rb +449 -440
  73. data/lib/when_exe/region/weekdate.rb +80 -80
  74. data/lib/when_exe/region/world.rb +170 -171
  75. data/lib/when_exe/region/world_season.rb +89 -89
  76. data/lib/when_exe/region/yerm.rb +3 -3
  77. data/lib/when_exe/region/zoroastrian.rb +205 -205
  78. data/lib/when_exe/timestandard.rb +708 -707
  79. data/lib/when_exe/tmduration.rb +338 -338
  80. data/lib/when_exe/tmobjects.rb +1356 -1356
  81. data/lib/when_exe/tmposition.rb +66 -31
  82. data/lib/when_exe/version.rb +16 -2
  83. data/test/examples/Residue.m17n +83 -83
  84. data/test/examples/Terms.m17n +2 -2
  85. data/test/test.rb +2 -2
  86. data/test/test/google_api.rb +65 -0
  87. data/test/test/linkeddata.rb +1 -1
  88. data/test/test/{googlecalendar.rb → obsolete/googlecalendar.rb} +194 -194
  89. data/test/test/region/indian.rb +90 -85
  90. data/test/test/region/m17n.rb +7 -7
  91. data/test/test/region/mayan.rb +195 -195
  92. data/test/test/region/residue.rb +153 -153
  93. data/test/test/tmposition.rb +11 -1
  94. data/when_exe.gemspec +2 -2
  95. metadata +95 -8
  96. data/test/test.rb.config +0 -1
@@ -1,85 +1,90 @@
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
- dates = When::CalendarNote::HinduNote::Dates.new(date)
54
- assert_equal(2448361, dates.to_i)
55
- assert_equal('Prajāpati', When.CalendarNote('HinduNote').samvatsara(dates)/'en')
56
- end
57
-
58
- def test_indian_date_4
59
- date = When.when? '2001.2.28'
60
- assert_equal('1922-12-09', (When::IndianNationalSolar ^ date).to_s)
61
- 399.times do
62
- date += When::P1Y
63
- assert_equal([12,9], (When::IndianNationalSolar ^ date).cal_date[-2..-1])
64
- end
65
- end
66
-
67
- def test_indian_date_5
68
- date = When.when? '2014.3.14'
69
- assert_equal('0546-01-01', (When::Nanakshahi ^ date).to_s)
70
- 399.times do
71
- date += When::P1Y
72
- assert_equal([1,1], (When::Nanakshahi ^ date).cal_date[-2..-1])
73
- end
74
- end
75
-
76
- def test_indian_date_6
77
- date = When.when? '2014.4.14'
78
- assert_equal('1421-01-01', (When::RevisedBengali ^ date).to_s)
79
- 399.times do
80
- date += When::P1Y
81
- assert_equal([1,1], (When::RevisedBengali ^ date).cal_date[-2..-1])
82
- end
83
- end
84
- end
85
- 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
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
+ dates = When::CalendarNote::HinduNote::Dates.new(date)
54
+ assert_equal(2448361, dates.to_i)
55
+ assert_equal('Prajāpati', When.CalendarNote('HinduNote').samvatsara(dates)/'en')
56
+ end
57
+
58
+ def test_indian_date_4
59
+ date = When.when? '2001.2.28'
60
+ assert_equal('1922-12-09', (When::IndianNationalSolar ^ date).to_s)
61
+ 399.times do
62
+ date += When::P1Y
63
+ assert_equal([12,9], (When::IndianNationalSolar ^ date).cal_date[-2..-1])
64
+ end
65
+ end
66
+
67
+ def test_indian_date_5
68
+ date = When.when? '2014.3.14'
69
+ assert_equal('0546-01-01', (When::Nanakshahi ^ date).to_s)
70
+ 399.times do
71
+ date += When::P1Y
72
+ assert_equal([1,1], (When::Nanakshahi ^ date).cal_date[-2..-1])
73
+ end
74
+ end
75
+
76
+ def test_indian_date_6
77
+ date = When.when? '2014.4.14'
78
+ assert_equal('1421-01-01', (When::RevisedBengali ^ date).to_s)
79
+ 399.times do
80
+ date += When::P1Y
81
+ assert_equal([1,1], (When::RevisedBengali ^ date).cal_date[-2..-1])
82
+ end
83
+ end
84
+
85
+ def test_indian_date_7
86
+ date = When.when? '1936-11%3C08-%5E%5eHinduLuniSolar?note=HinduNote&location=(_co:Indian::Chennai)&start_month=5&type=SBSA'
87
+ assert_equal('1936-11<08-', date.to_s)
88
+ end
89
+ end
90
+ end
@@ -12,9 +12,9 @@ module MiniTest
12
12
 
13
13
  First = [
14
14
  ["Calendar", "Calendar", nil],
15
- ["Month", "", "http://ja.wikipedia.org/wiki/%E6%9C%88_(%E6%9A%A6)"],
16
- ["Month", "", "http://ja.wikipedia.org/wiki/%E6%9C%88_(%E6%9A%A6)"],
17
- ["January", "1月", "http://ja.wikipedia.org/wiki/1%E6%9C%88"]
15
+ ["Month", "月の名前", "http://ja.wikipedia.org/wiki/%E6%9C%88_(%E6%9A%A6)"],
16
+ ["Month", "月の名前", "http://ja.wikipedia.org/wiki/%E6%9C%88_(%E6%9A%A6)"],
17
+ ["January", "1月", "http://ja.wikipedia.org/wiki/1%E6%9C%88"]
18
18
  ]
19
19
 
20
20
  Second = [
@@ -117,7 +117,7 @@ module MiniTest
117
117
 
118
118
  def test__m17n_5
119
119
  month = When.Resource('_m:Calendar::Month')
120
- [['en', 'Month'], ['ja', ''], ['fr', 'Mois']].each do |sample|
120
+ [['en', 'month name'], ['ja', '月の名前']].each do |sample|
121
121
  assert_equal(sample[1], month.translate(sample[0]))
122
122
  end
123
123
  end
@@ -133,7 +133,7 @@ module MiniTest
133
133
 
134
134
  ['1985-1-1',
135
135
  {:calendar=>["Gregorian"], :sdn=>2446067, :cal_date=>[1985, 1, 1],
136
- :notes=>[[{:note=>"Month", :value=>"January"}],[{:note=>"Week", :value=>"Tuesday(1)"}]], :locale=>'en'}],
136
+ :notes=>[[{:note=>"month name", :value=>"January"}],[{:note=>"Week", :value=>"Tuesday(1)"}]], :locale=>'en'}],
137
137
 
138
138
  ['明治7.5.7',
139
139
  {:calendar=>["明治",1867], :sdn=>2405651, :cal_date=>[7, 5, 7],
@@ -153,7 +153,7 @@ module MiniTest
153
153
 
154
154
  ['CE-2010.06.08T12:00:00+09:00',
155
155
  {:calendar=>["BeforeCommonEra", 1, true], :sdn=>987064, :cal_date=>[-2011, 6, 8],
156
- :notes=>[[{:note=>"Month", :value=>"June"}],[]], :locale=>'en',
156
+ :notes=>[[{:note=>"month name", :value=>"June"}],[]], :locale=>'en',
157
157
  :clk_time=>[987064, 12, 0, 0]}],
158
158
 
159
159
  [11,
@@ -184,7 +184,7 @@ module MiniTest
184
184
  :Precision=>0,
185
185
  :Sdn=>2456388,
186
186
  :Calendar=>["Gregorian"],
187
- :Notes=>[[{:Note=>"Month", :Value=>"April"}],
187
+ :Notes=>[[{:Note=>"month name", :Value=>"April"}],
188
188
  [{:Note=>"Week", :Value=>"Friday(4)"}]],
189
189
  :CalDate=>[2013, 4, 5]},
190
190
  When.when?('2013-4-5').to_h(:method=>:to_m17n, :locale=>'en', :camel=>true))
@@ -1,195 +1,195 @@
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 Mayan < MiniTest::TestCase
12
- def test__mayan_epoch
13
- # No offset
14
- [['PHLC13.0.0.0.0', 'PHLC13(00).00.00.00.00', 584283],
15
- ['HLC0.0.0.0.1', 'HLC00.00.00.00.01', 584284],
16
- ['HLC13.0.0.0.0', 'HLC13.00.00.00.00', 2456283],
17
- ['HLC13.0.0.0.1', 'NLC00(13).00.00.00.01', 2456284]].each do |sample|
18
- date = When.when?(sample.shift)
19
- assert_equal(sample, [date.to_s, date.to_i])
20
- end
21
-
22
- # offset 0B
23
- [['LongCount?Epoch=0D::PHLC13.0.0.0.0', 'LongCount?Epoch=0D::PHLC13(00).00.00.00.00', 584283],
24
- ['LongCount?Epoch=0D::HLC0.0.0.0.1', 'LongCount?Epoch=0D::HLC00.00.00.00.01', 584284],
25
- ['LongCount?Epoch=0D::HLC13.0.0.0.0', 'LongCount?Epoch=0D::HLC13.00.00.00.00', 2456283],
26
- ['LongCount?Epoch=0D::HLC13.0.0.0.1', 'LongCount?Epoch=0D::NLC00(13).00.00.00.01', 2456284]].each do |sample|
27
- date = When.when?(sample.shift)
28
- assert_equal(sample, [date.to_s, date.to_i])
29
- end
30
-
31
- # offset 2B
32
- [['LongCount?Epoch=2D::PHLC13.0.0.0.0', 'LongCount?Epoch=2D::PHLC13(00).00.00.00.00', 584285],
33
- ['LongCount?Epoch=2D::HLC0.0.0.0.1', 'LongCount?Epoch=2D::HLC00.00.00.00.01', 584286],
34
- ['LongCount?Epoch=2D::HLC13.0.0.0.0', 'LongCount?Epoch=2D::HLC13.00.00.00.00', 2456285],
35
- ['LongCount?Epoch=2D::HLC13.0.0.0.1', 'LongCount?Epoch=2D::NLC00(13).00.00.00.01', 2456286]].each do |sample|
36
- date = When.when?(sample.shift)
37
- assert_equal(sample, [date.to_s, date.to_i])
38
- end
39
- end
40
-
41
- def test__mayan_period
42
- date = When.when?('HLC0.0.0.0.1')
43
- period = When.Duration('P2X1X3Y4M5D')
44
- assert_equal('HLC02.01.03.04.06', (date + period).to_s)
45
- end
46
-
47
- def test__haab
48
- # No offset
49
- haab = When.Resource("_co:Mayan::Haab'")
50
- assert_equal("ハアブ", haab.label.translate('ja'))
51
- assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
52
- pop = When.Resource("_co:Mayan::Haab'::Pop")
53
- assert_equal("Pop", pop.label.translate('en'))
54
- assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
55
- date0 = When.when?('2011-05-16T12:34:56Z')
56
- sample = [
57
- "2012-04-12T12:34:56Z",
58
- "2012-04-13T12:34:56Z",
59
- "2012-04-14T12:34:56Z"
60
- ]
61
- [10,11,12].each do |i|
62
- assert_equal(sample.shift, (date0 & pop[i]).to_s)
63
- end
64
- assert_equal(42, When.when?('2011-05-15') % haab)
65
- h = haab % When.when?('2011-05-15')
66
- assert_equal(["Sip", 2], [h.label.to_s, h.difference])
67
-
68
- # offset 0B
69
- haab = When.Resource("_co:Mayan?Epoch=0D::Haab'")
70
- assert_equal("ハアブ", haab.label.translate('ja'))
71
- assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
72
- pop = When.Resource("_co:Mayan?Epoch=0D::Haab'::Pop")
73
- assert_equal("Pop", pop.label.translate('en'))
74
- assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
75
- date0 = When.when?('2011-05-16T12:34:56Z')
76
- sample = [
77
- "2012-04-12T12:34:56Z",
78
- "2012-04-13T12:34:56Z",
79
- "2012-04-14T12:34:56Z"
80
- ]
81
- [10,11,12].each do |i|
82
- assert_equal(sample.shift, (date0 & pop[i]).to_s)
83
- end
84
- assert_equal(42, When.when?('2011-05-15') % haab)
85
- h = haab % When.when?('2011-05-15')
86
- assert_equal(["Sip", 2], [h.label.to_s, h.difference])
87
-
88
- # offset 2B
89
- haab = When.Resource("_co:Mayan?Epoch=2D::Haab'")
90
- assert_equal("ハアブ", haab.label.translate('ja'))
91
- assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
92
- pop = When.Resource("_co:Mayan?Epoch=2D::Haab'::Pop")
93
- assert_equal("Pop", pop.label.translate('en'))
94
- assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
95
- date0 = When.when?('2011-05-16T12:34:56Z')
96
- sample = [
97
- "2012-04-14T12:34:56Z",
98
- "2012-04-15T12:34:56Z",
99
- "2012-04-16T12:34:56Z"
100
- ]
101
- [10,11,12].each do |i|
102
- assert_equal(sample.shift, (date0 & pop[i]).to_s)
103
- end
104
- assert_equal(42, When.when?('2011-05-17') % haab)
105
- h = haab % When.when?('2011-05-17')
106
- assert_equal(["Sip", 2], [h.label.to_s, h.difference])
107
- end
108
-
109
- def test__tzolkin
110
- # No offset
111
- trecena = When.Resource("_co:Mayan::Trecena")
112
- assert_equal("トレセナ", trecena.label.translate('ja'))
113
- assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
114
- assert_equal(2, When.when?('2011-05-15') % trecena)
115
-
116
-
117
- tzolkin = When.Resource("_co:Mayan::Tzolk'in")
118
- assert_equal("ツォルキン", tzolkin.label.translate('ja'))
119
- assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
120
- ajaw = When.Resource("_co:Mayan::Tzolk'in::Ajaw")
121
- assert_equal("Ajaw", ajaw.label.translate('en'))
122
- assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
123
- date0 = When.when?('2011-05-16T12:34:56Z')
124
- sample = [
125
- "2011-05-21T12:34:56Z",
126
- "2011-05-21T12:34:56Z",
127
- "2011-05-21T12:34:56Z"
128
- ]
129
- [10,11,12].each do |i|
130
- assert_equal(sample.shift, (date0 & ajaw).to_s)
131
- end
132
- assert_equal(13, When.when?('2011-05-15') % tzolkin)
133
- assert_equal('Ix', (tzolkin % When.when?('2011-05-15')).label.to_s)
134
- if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
135
- assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
136
- end
137
-
138
- # offset 0B
139
- trecena = When.Resource("_co:Mayan?Epoch=0D::Trecena")
140
- assert_equal("トレセナ", trecena.label.translate('ja'))
141
- assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
142
- assert_equal(2, When.when?('2011-05-15') % trecena)
143
-
144
-
145
- tzolkin = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in")
146
- assert_equal("ツォルキン", tzolkin.label.translate('ja'))
147
- assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
148
- ajaw = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in::Ajaw")
149
- assert_equal("Ajaw", ajaw.label.translate('en'))
150
- assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
151
- date0 = When.when?('2011-05-16T12:34:56Z')
152
- sample = [
153
- "2011-05-21T12:34:56Z",
154
- "2011-05-21T12:34:56Z",
155
- "2011-05-21T12:34:56Z"
156
- ]
157
- [10,11,12].each do |i|
158
- assert_equal(sample.shift, (date0 & ajaw).to_s)
159
- end
160
- assert_equal(13, When.when?('2011-05-15') % tzolkin)
161
- assert_equal('Ix', (tzolkin % When.when?('2011-05-15')).label.to_s)
162
- if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
163
- assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
164
- end
165
-
166
- # offset 2B
167
- trecena = When.Resource("_co:Mayan?Epoch=2D::Trecena")
168
- assert_equal("トレセナ", trecena.label.translate('ja'))
169
- assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
170
- assert_equal(2, When.when?('2011-05-17') % trecena)
171
-
172
-
173
- tzolkin = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in")
174
- assert_equal("ツォルキン", tzolkin.label.translate('ja'))
175
- assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
176
- ajaw = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in::Ajaw")
177
- assert_equal("Ajaw", ajaw.label.translate('en'))
178
- assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
179
- date0 = When.when?('2011-05-16T12:34:56Z')
180
- sample = [
181
- "2011-05-23T12:34:56Z",
182
- "2011-05-23T12:34:56Z",
183
- "2011-05-23T12:34:56Z"
184
- ]
185
- [10,11,12].each do |i|
186
- assert_equal(sample.shift, (date0 & ajaw).to_s)
187
- end
188
- assert_equal(13, When.when?('2011-05-17') % tzolkin)
189
- assert_equal('Ix', (tzolkin % When.when?('2011-05-17')).label.to_s)
190
- if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
191
- assert_equal('Ix', (tzolkin % Date.new(2011,5,17)).label.to_s)
192
- end
193
- end
194
- end
195
- 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
10
+
11
+ class Mayan < MiniTest::TestCase
12
+ def test__mayan_epoch
13
+ # No offset
14
+ [['PHLC13.0.0.0.0', 'PHLC13(00).00.00.00.00', 584283],
15
+ ['HLC0.0.0.0.1', 'HLC00.00.00.00.01', 584284],
16
+ ['HLC13.0.0.0.0', 'HLC13.00.00.00.00', 2456283],
17
+ ['HLC13.0.0.0.1', 'NLC00(13).00.00.00.01', 2456284]].each do |sample|
18
+ date = When.when?(sample.shift)
19
+ assert_equal(sample, [date.to_s, date.to_i])
20
+ end
21
+
22
+ # offset 0B
23
+ [['LongCount?Epoch=0D::PHLC13.0.0.0.0', 'LongCount?Epoch=0D::PHLC13(00).00.00.00.00', 584283],
24
+ ['LongCount?Epoch=0D::HLC0.0.0.0.1', 'LongCount?Epoch=0D::HLC00.00.00.00.01', 584284],
25
+ ['LongCount?Epoch=0D::HLC13.0.0.0.0', 'LongCount?Epoch=0D::HLC13.00.00.00.00', 2456283],
26
+ ['LongCount?Epoch=0D::HLC13.0.0.0.1', 'LongCount?Epoch=0D::NLC00(13).00.00.00.01', 2456284]].each do |sample|
27
+ date = When.when?(sample.shift)
28
+ assert_equal(sample, [date.to_s, date.to_i])
29
+ end
30
+
31
+ # offset 2B
32
+ [['LongCount?Epoch=2D::PHLC13.0.0.0.0', 'LongCount?Epoch=2D::PHLC13(00).00.00.00.00', 584285],
33
+ ['LongCount?Epoch=2D::HLC0.0.0.0.1', 'LongCount?Epoch=2D::HLC00.00.00.00.01', 584286],
34
+ ['LongCount?Epoch=2D::HLC13.0.0.0.0', 'LongCount?Epoch=2D::HLC13.00.00.00.00', 2456285],
35
+ ['LongCount?Epoch=2D::HLC13.0.0.0.1', 'LongCount?Epoch=2D::NLC00(13).00.00.00.01', 2456286]].each do |sample|
36
+ date = When.when?(sample.shift)
37
+ assert_equal(sample, [date.to_s, date.to_i])
38
+ end
39
+ end
40
+
41
+ def test__mayan_period
42
+ date = When.when?('HLC0.0.0.0.1')
43
+ period = When.Duration('P2X1X3Y4M5D')
44
+ assert_equal('HLC02.01.03.04.06', (date + period).to_s)
45
+ end
46
+
47
+ def test__haab
48
+ # No offset
49
+ haab = When.Resource("_co:Mayan::Haab'")
50
+ assert_equal("ハアブ", haab.label.translate('ja'))
51
+ assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
52
+ pop = When.Resource("_co:Mayan::Haab'::Pop")
53
+ assert_equal("Pop", pop.label.translate('en'))
54
+ assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
55
+ date0 = When.when?('2011-05-16T12:34:56Z')
56
+ sample = [
57
+ "2012-04-12T12:34:56Z",
58
+ "2012-04-13T12:34:56Z",
59
+ "2012-04-14T12:34:56Z"
60
+ ]
61
+ [10,11,12].each do |i|
62
+ assert_equal(sample.shift, (date0 & pop[i]).to_s)
63
+ end
64
+ assert_equal(42, When.when?('2011-05-15') % haab)
65
+ h = haab % When.when?('2011-05-15')
66
+ assert_equal(["Sip", 2], [h.label.to_s, h.difference])
67
+
68
+ # offset 0B
69
+ haab = When.Resource("_co:Mayan?Epoch=0D::Haab'")
70
+ assert_equal("ハアブ", haab.label.translate('ja'))
71
+ assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
72
+ pop = When.Resource("_co:Mayan?Epoch=0D::Haab'::Pop")
73
+ assert_equal("Pop", pop.label.translate('en'))
74
+ assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
75
+ date0 = When.when?('2011-05-16T12:34:56Z')
76
+ sample = [
77
+ "2012-04-12T12:34:56Z",
78
+ "2012-04-13T12:34:56Z",
79
+ "2012-04-14T12:34:56Z"
80
+ ]
81
+ [10,11,12].each do |i|
82
+ assert_equal(sample.shift, (date0 & pop[i]).to_s)
83
+ end
84
+ assert_equal(42, When.when?('2011-05-15') % haab)
85
+ h = haab % When.when?('2011-05-15')
86
+ assert_equal(["Sip", 2], [h.label.to_s, h.difference])
87
+
88
+ # offset 2B
89
+ haab = When.Resource("_co:Mayan?Epoch=2D::Haab'")
90
+ assert_equal("ハアブ", haab.label.translate('ja'))
91
+ assert_equal("http://en.wikipedia.org/wiki/Haab'", haab.label.reference)
92
+ pop = When.Resource("_co:Mayan?Epoch=2D::Haab'::Pop")
93
+ assert_equal("Pop", pop.label.translate('en'))
94
+ assert_equal("http://en.wikipedia.org/wiki/File:Maya-Pop.jpg", pop.label.reference)
95
+ date0 = When.when?('2011-05-16T12:34:56Z')
96
+ sample = [
97
+ "2012-04-14T12:34:56Z",
98
+ "2012-04-15T12:34:56Z",
99
+ "2012-04-16T12:34:56Z"
100
+ ]
101
+ [10,11,12].each do |i|
102
+ assert_equal(sample.shift, (date0 & pop[i]).to_s)
103
+ end
104
+ assert_equal(42, When.when?('2011-05-17') % haab)
105
+ h = haab % When.when?('2011-05-17')
106
+ assert_equal(["Sip", 2], [h.label.to_s, h.difference])
107
+ end
108
+
109
+ def test__tzolkin
110
+ # No offset
111
+ trecena = When.Resource("_co:Mayan::Trecena::Trecena")
112
+ assert_equal("トレセナ", trecena.label.translate('ja'))
113
+ assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
114
+ assert_equal(2, When.when?('2011-05-15') % trecena)
115
+
116
+
117
+ tzolkin = When.Resource("_co:Mayan::Tzolk'in")
118
+ assert_equal("ツォルキン", tzolkin.label.translate('ja'))
119
+ assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
120
+ ajaw = When.Resource("_co:Mayan::Tzolk'in::Ajaw")
121
+ assert_equal("Ajaw", ajaw.label.translate('en'))
122
+ assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
123
+ date0 = When.when?('2011-05-16T12:34:56Z')
124
+ sample = [
125
+ "2011-05-21T12:34:56Z",
126
+ "2011-05-21T12:34:56Z",
127
+ "2011-05-21T12:34:56Z"
128
+ ]
129
+ [10,11,12].each do |i|
130
+ assert_equal(sample.shift, (date0 & ajaw).to_s)
131
+ end
132
+ assert_equal(13, When.when?('2011-05-15') % tzolkin)
133
+ assert_equal('Ix', (tzolkin % When.when?('2011-05-15')).label.to_s)
134
+ if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
135
+ assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
136
+ end
137
+
138
+ # offset 0B
139
+ trecena = When.Resource("_co:Mayan?Epoch=0D::Trecena::Trecena")
140
+ assert_equal("トレセナ", trecena.label.translate('ja'))
141
+ assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
142
+ assert_equal(2, When.when?('2011-05-15') % trecena)
143
+
144
+
145
+ tzolkin = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in")
146
+ assert_equal("ツォルキン", tzolkin.label.translate('ja'))
147
+ assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
148
+ ajaw = When.Resource("_co:Mayan?Epoch=0D::Tzolk'in::Ajaw")
149
+ assert_equal("Ajaw", ajaw.label.translate('en'))
150
+ assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
151
+ date0 = When.when?('2011-05-16T12:34:56Z')
152
+ sample = [
153
+ "2011-05-21T12:34:56Z",
154
+ "2011-05-21T12:34:56Z",
155
+ "2011-05-21T12:34:56Z"
156
+ ]
157
+ [10,11,12].each do |i|
158
+ assert_equal(sample.shift, (date0 & ajaw).to_s)
159
+ end
160
+ assert_equal(13, When.when?('2011-05-15') % tzolkin)
161
+ assert_equal('Ix', (tzolkin % When.when?('2011-05-15')).label.to_s)
162
+ if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
163
+ assert_equal('Ix', (tzolkin % Date.new(2011,5,15)).label.to_s)
164
+ end
165
+
166
+ # offset 2B
167
+ trecena = When.Resource("_co:Mayan?Epoch=2D::Trecena::Trecena")
168
+ assert_equal("トレセナ", trecena.label.translate('ja'))
169
+ assert_equal("http://en.wikipedia.org/wiki/Trecena", trecena.label.reference)
170
+ assert_equal(2, When.when?('2011-05-17') % trecena)
171
+
172
+
173
+ tzolkin = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in")
174
+ assert_equal("ツォルキン", tzolkin.label.translate('ja'))
175
+ assert_equal("http://en.wikipedia.org/wiki/Tzolk'in", tzolkin.label.reference)
176
+ ajaw = When.Resource("_co:Mayan?Epoch=2D::Tzolk'in::Ajaw")
177
+ assert_equal("Ajaw", ajaw.label.translate('en'))
178
+ assert_equal("http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-D20-Ajaw-cdxW.png", ajaw.label.reference('alias'))
179
+ date0 = When.when?('2011-05-16T12:34:56Z')
180
+ sample = [
181
+ "2011-05-23T12:34:56Z",
182
+ "2011-05-23T12:34:56Z",
183
+ "2011-05-23T12:34:56Z"
184
+ ]
185
+ [10,11,12].each do |i|
186
+ assert_equal(sample.shift, (date0 & ajaw).to_s)
187
+ end
188
+ assert_equal(13, When.when?('2011-05-17') % tzolkin)
189
+ assert_equal('Ix', (tzolkin % When.when?('2011-05-17')).label.to_s)
190
+ if ::Object.const_defined?(:Date) && Date.respond_to?(:civil)
191
+ assert_equal('Ix', (tzolkin % Date.new(2011,5,17)).label.to_s)
192
+ end
193
+ end
194
+ end
195
+ end