when_exe 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +171 -0
- data/lib/when_exe.rb +78 -47
- data/lib/when_exe/basictypes.rb +752 -747
- data/lib/when_exe/calendarnote.rb +805 -801
- data/lib/when_exe/calendartypes.rb +1583 -1531
- data/lib/when_exe/coordinates.rb +16 -15
- data/lib/when_exe/core/duration.rb +114 -110
- data/lib/when_exe/core/extension.rb +504 -504
- data/lib/when_exe/ephemeris.rb +1917 -1913
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/ephemeris/notes.rb +389 -387
- data/lib/when_exe/ephemeris/planets.rb +585 -585
- data/lib/when_exe/ephemeris/sun.rb +214 -214
- data/lib/when_exe/googlecalendar.rb +144 -140
- data/lib/when_exe/icalendar.rb +1636 -1636
- data/lib/when_exe/inspect.rb +46 -22
- data/lib/when_exe/locales/akt.rb +176 -176
- data/lib/when_exe/locales/encoding_conversion.rb +134 -126
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/locale.rb +750 -746
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/mini_application.rb +307 -305
- data/lib/when_exe/parts/enumerator.rb +2 -2
- data/lib/when_exe/parts/geometric_complex.rb +397 -397
- data/lib/when_exe/parts/method_cash.rb +224 -224
- data/lib/when_exe/parts/resource.rb +1069 -1071
- data/lib/when_exe/parts/timezone.rb +240 -230
- data/lib/when_exe/region/armenian.rb +56 -56
- data/lib/when_exe/region/babylonian.rb +405 -0
- data/lib/when_exe/region/bahai.rb +146 -146
- data/lib/when_exe/region/balinese.rb +622 -622
- data/lib/when_exe/region/chinese.rb +95 -25
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/chinese/epochs.rb +1 -1
- data/lib/when_exe/region/chinese/twins.rb +803 -795
- data/lib/when_exe/region/christian.rb +824 -824
- data/lib/when_exe/region/coptic.rb +106 -87
- data/lib/when_exe/region/discordian.rb +225 -225
- data/lib/when_exe/region/far_east.rb +188 -188
- data/lib/when_exe/region/french.rb +56 -56
- data/lib/when_exe/region/geologicalage.rb +639 -639
- data/lib/when_exe/region/goddess.rb +58 -58
- data/lib/when_exe/region/indian.rb +1254 -1251
- data/lib/when_exe/region/iranian.rb +8 -8
- data/lib/when_exe/region/islamic.rb +3 -3
- data/lib/when_exe/region/japanese.rb +93 -99
- data/lib/when_exe/region/japanese/calendars.rb +396 -397
- data/lib/when_exe/region/japanese/epochs.rb +26 -26
- data/lib/when_exe/region/japanese/nihon_shoki.rb +71 -71
- data/lib/when_exe/region/japanese/notes.rb +1383 -1386
- data/lib/when_exe/region/japanese/residues.rb +1306 -1306
- data/lib/when_exe/region/japanese/twins.rb +225 -225
- data/lib/when_exe/region/japanese/weeks.rb +112 -0
- data/lib/when_exe/region/javanese.rb +230 -230
- data/lib/when_exe/region/jewish.rb +126 -126
- data/lib/when_exe/region/korean.rb +378 -378
- data/lib/when_exe/region/m17n.rb +114 -113
- data/lib/when_exe/region/martian.rb +258 -255
- data/lib/when_exe/region/mayan.rb +32 -32
- data/lib/when_exe/region/residue.rb +89 -89
- data/lib/when_exe/region/roman.rb +36 -24
- data/lib/when_exe/region/ryukyu.rb +97 -97
- data/lib/when_exe/region/shire.rb +240 -240
- data/lib/when_exe/region/soviet.rb +209 -0
- data/lib/when_exe/region/symmetry.rb +50 -50
- data/lib/when_exe/region/thai.rb +336 -335
- data/lib/when_exe/region/tibetan.rb +316 -315
- data/lib/when_exe/region/vietnamese.rb +440 -439
- data/lib/when_exe/region/weekdate.rb +80 -80
- data/lib/when_exe/region/world.rb +175 -175
- data/lib/when_exe/region/yerm.rb +14 -14
- data/lib/when_exe/region/zoroastrian.rb +203 -203
- data/lib/when_exe/timestandard.rb +707 -681
- data/lib/when_exe/tmduration.rb +338 -330
- data/lib/when_exe/tmobjects.rb +1346 -1325
- data/lib/when_exe/tmposition.rb +2115 -2072
- data/lib/when_exe/tmreference.rb +1693 -1669
- data/lib/when_exe/version.rb +1 -1
- data/link_to_online_documents +1 -1
- data/test/examples/JapanHolidaysRFC6350.ics +1 -1
- data/test/test.rb +67 -61
- data/test/test/basictypes.rb +409 -409
- data/test/test/calendarnote.rb +86 -69
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +396 -396
- data/test/test/ephemeris.rb +83 -74
- data/test/test/ephemeris/moon.rb +14 -14
- data/test/test/ephemeris/planets.rb +14 -14
- data/test/test/ephemeris/sun.rb +14 -14
- data/test/test/googlecalendar.rb +194 -176
- data/test/test/icalendar.rb +867 -858
- data/test/test/inspect.rb +117 -117
- data/test/test/parts.rb +487 -487
- data/test/test/region/balinese.rb +34 -0
- data/test/test/region/chinese.rb +218 -206
- data/test/test/region/christian.rb +245 -245
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/indian.rb +57 -57
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +18 -18
- data/test/test/region/japanese.rb +237 -219
- data/test/test/region/jewish.rb +61 -61
- data/test/test/region/m17n.rb +184 -184
- data/test/test/region/mayan.rb +195 -195
- data/test/test/region/residue.rb +147 -139
- data/test/test/region/thai.rb +116 -116
- data/test/test/region/tibetan.rb +30 -30
- data/test/test/region/vietnamese.rb +102 -102
- data/test/test/region/yerm.rb +146 -146
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +328 -328
- data/test/test/tmposition.rb +397 -284
- data/test/test/tmreference.rb +157 -157
- metadata +13 -10
data/test/test/ephemeris.rb
CHANGED
@@ -1,74 +1,83 @@
|
|
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
|
10
|
-
|
11
|
-
class Ephemeris <
|
12
|
-
def test_nothing
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class CelestialObject <
|
17
|
-
def test_nothing
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Star <
|
22
|
-
|
23
|
-
def test_nothing
|
24
|
-
end
|
25
|
-
|
26
|
-
# 恒星
|
27
|
-
class Fixed <
|
28
|
-
def test__access_hr
|
29
|
-
polaris = When::Resource('_sc:HR0424')
|
30
|
-
assert_equal("Alp UMi", polaris.bayer_name)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# 春分点
|
35
|
-
class Vernal <
|
36
|
-
def test_nothing
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# 北極
|
41
|
-
class Pole <
|
42
|
-
def test_nothing
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Planet <
|
48
|
-
def test_nothing
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class Coords <
|
53
|
-
def test_nothing
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Formula <
|
58
|
-
def test__sunrise
|
59
|
-
|
60
|
-
today = '2014-3-4'
|
61
|
-
|
62
|
-
assert_raises(NoMethodError) { When.when?(today).sunrise }
|
63
|
-
|
64
|
-
location = When.Location('long=139.413012E&lat=35.412222N')
|
65
|
-
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today, {:location=>location}).sunrise.to_s)
|
66
|
-
|
67
|
-
When::Coordinates::Spatial.default_location = location
|
68
|
-
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today).sunrise.to_s)
|
69
|
-
|
70
|
-
When::TM::Clock.local_time = '+09:00'
|
71
|
-
assert_equal(0, /2014-03-04T06:07/ =~ When.when?(today).sunrise.to_s)
|
72
|
-
end
|
73
|
-
|
74
|
-
|
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::Ephemeris
|
10
|
+
|
11
|
+
class Ephemeris < MiniTest::TestCase
|
12
|
+
def test_nothing
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class CelestialObject < MiniTest::TestCase
|
17
|
+
def test_nothing
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Star < MiniTest::TestCase
|
22
|
+
|
23
|
+
def test_nothing
|
24
|
+
end
|
25
|
+
|
26
|
+
# 恒星
|
27
|
+
class Fixed < MiniTest::TestCase
|
28
|
+
def test__access_hr
|
29
|
+
polaris = When::Resource('_sc:HR0424')
|
30
|
+
assert_equal("Alp UMi", polaris.bayer_name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# 春分点
|
35
|
+
class Vernal < MiniTest::TestCase
|
36
|
+
def test_nothing
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# 北極
|
41
|
+
class Pole < MiniTest::TestCase
|
42
|
+
def test_nothing
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Planet < MiniTest::TestCase
|
48
|
+
def test_nothing
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Coords < MiniTest::TestCase
|
53
|
+
def test_nothing
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Formula < MiniTest::TestCase
|
58
|
+
def test__sunrise
|
59
|
+
|
60
|
+
today = '2014-3-4'
|
61
|
+
|
62
|
+
assert_raises(NoMethodError) { When.when?(today).sunrise }
|
63
|
+
|
64
|
+
location = When.Location('long=139.413012E&lat=35.412222N')
|
65
|
+
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today, {:location=>location}).sunrise.to_s)
|
66
|
+
|
67
|
+
When::Coordinates::Spatial.default_location = location
|
68
|
+
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today).sunrise.to_s)
|
69
|
+
|
70
|
+
When::TM::Clock.local_time = '+09:00'
|
71
|
+
assert_equal(0, /2014-03-04T06:07/ =~ When.when?(today).sunrise.to_s)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test__lunisolar_location
|
75
|
+
formula1 = When.Resource('_ep:Formula?formula=1L')
|
76
|
+
formula2 = When.Resource('_ep:Formula?formula=12S')
|
77
|
+
date = When.when?('2014-08-01', :clock=>'+09:00')
|
78
|
+
assert_equal('2014-07-27T07:41+09:00', formula1.nearest_past(date).floor(When::MINUTE).to_s)
|
79
|
+
assert_equal('2014-07-23T06:41+09:00', formula2.nearest_past(date).floor(When::MINUTE).to_s)
|
80
|
+
assert_equal('2014-07-07T13:15+09:00', formula2.nearest_past(date, 0.5).floor(When::MINUTE).to_s)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/test/test/ephemeris/moon.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
10
|
-
class Moon <
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
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::Ephemeris
|
10
|
+
class Moon < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,14 +1,14 @@
|
|
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
|
10
|
-
class Planets <
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
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::Ephemeris
|
10
|
+
class Planets < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/test/ephemeris/sun.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
10
|
-
class Sun <
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
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::Ephemeris
|
10
|
+
class Sun < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/test/googlecalendar.rb
CHANGED
@@ -1,176 +1,194 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2012-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
|
10
|
-
|
11
|
-
class GoogleCalendar <
|
12
|
-
|
13
|
-
config = ::When.config
|
14
|
-
ACCOUNT, PASSWORD = config['@'] if config.key?('@')
|
15
|
-
|
16
|
-
PUBLIC_FEED = "http://www.google.com/calendar/feeds/%s__%s%%40holiday.calendar.google.com/public/full"
|
17
|
-
PRIVATE_FEED = "http://www.google.com/calendar/feeds/%s%%40gmail.com/private/full"
|
18
|
-
YEAR = "1949"
|
19
|
-
RULE0 = <<RULE0
|
20
|
-
DTSTART;VALUE=DATE:19490101
|
21
|
-
DTEND;VALUE=DATE:19490102
|
22
|
-
RRULE:FREQ=YEARLY
|
23
|
-
RULE0
|
24
|
-
RULE1 = <<RULE1
|
25
|
-
RRULE:FREQ=YEARLY
|
26
|
-
DTSTART;TZID=America/New_York:#{YEAR}0321T120000
|
27
|
-
DTEND;TZID=America/New_York:#{YEAR}0322T130000
|
28
|
-
RULE1
|
29
|
-
RECURRENCE = <<RECURRENCE
|
30
|
-
DTSTART;TZID=America/New_York:#{YEAR}0321T120000
|
31
|
-
DTEND;TZID=America/New_York:#{YEAR}0322T130000
|
32
|
-
RRULE:FREQ=YEARLY
|
33
|
-
BEGIN:VTIMEZONE
|
34
|
-
TZID:America/New_York
|
35
|
-
X-LIC-LOCATION:America/New_York
|
36
|
-
BEGIN:DAYLIGHT
|
37
|
-
TZOFFSETFROM:-0500
|
38
|
-
TZOFFSETTO:-0400
|
39
|
-
TZNAME:EDT
|
40
|
-
DTSTART:19700308T020000
|
41
|
-
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
|
42
|
-
END:DAYLIGHT
|
43
|
-
BEGIN:STANDARD
|
44
|
-
TZOFFSETFROM:-0400
|
45
|
-
TZOFFSETTO:-0500
|
46
|
-
TZNAME:EST
|
47
|
-
DTSTART:19701101T020000
|
48
|
-
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
|
49
|
-
END:STANDARD
|
50
|
-
END:VTIMEZONE
|
51
|
-
RECURRENCE
|
52
|
-
|
53
|
-
|
54
|
-
["元日", "
|
55
|
-
["
|
56
|
-
["銀行休業日", "
|
57
|
-
["
|
58
|
-
["
|
59
|
-
["
|
60
|
-
["
|
61
|
-
["
|
62
|
-
["
|
63
|
-
["
|
64
|
-
["
|
65
|
-
["
|
66
|
-
["
|
67
|
-
["
|
68
|
-
["
|
69
|
-
["
|
70
|
-
["文化の日",
|
71
|
-
["勤労感謝の日", "
|
72
|
-
["天皇誕生日", "
|
73
|
-
["
|
74
|
-
["
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
holidays.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
=
|
135
|
-
|
136
|
-
|
137
|
-
gcal
|
138
|
-
|
139
|
-
|
140
|
-
assert_equal(
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2012-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 GoogleCalendar < MiniTest::TestCase
|
12
|
+
|
13
|
+
config = ::When.config
|
14
|
+
ACCOUNT, PASSWORD = config['@'] if config.key?('@')
|
15
|
+
|
16
|
+
PUBLIC_FEED = "http://www.google.com/calendar/feeds/%s__%s%%40holiday.calendar.google.com/public/full"
|
17
|
+
PRIVATE_FEED = "http://www.google.com/calendar/feeds/%s%%40gmail.com/private/full"
|
18
|
+
YEAR = "1949"
|
19
|
+
RULE0 = <<RULE0
|
20
|
+
DTSTART;VALUE=DATE:19490101
|
21
|
+
DTEND;VALUE=DATE:19490102
|
22
|
+
RRULE:FREQ=YEARLY
|
23
|
+
RULE0
|
24
|
+
RULE1 = <<RULE1
|
25
|
+
RRULE:FREQ=YEARLY
|
26
|
+
DTSTART;TZID=America/New_York:#{YEAR}0321T120000
|
27
|
+
DTEND;TZID=America/New_York:#{YEAR}0322T130000
|
28
|
+
RULE1
|
29
|
+
RECURRENCE = <<RECURRENCE
|
30
|
+
DTSTART;TZID=America/New_York:#{YEAR}0321T120000
|
31
|
+
DTEND;TZID=America/New_York:#{YEAR}0322T130000
|
32
|
+
RRULE:FREQ=YEARLY
|
33
|
+
BEGIN:VTIMEZONE
|
34
|
+
TZID:America/New_York
|
35
|
+
X-LIC-LOCATION:America/New_York
|
36
|
+
BEGIN:DAYLIGHT
|
37
|
+
TZOFFSETFROM:-0500
|
38
|
+
TZOFFSETTO:-0400
|
39
|
+
TZNAME:EDT
|
40
|
+
DTSTART:19700308T020000
|
41
|
+
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
|
42
|
+
END:DAYLIGHT
|
43
|
+
BEGIN:STANDARD
|
44
|
+
TZOFFSETFROM:-0400
|
45
|
+
TZOFFSETTO:-0500
|
46
|
+
TZNAME:EST
|
47
|
+
DTSTART:19701101T020000
|
48
|
+
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
|
49
|
+
END:STANDARD
|
50
|
+
END:VTIMEZONE
|
51
|
+
RECURRENCE
|
52
|
+
|
53
|
+
HOLIDAYS1 = [ # Public Feed
|
54
|
+
["元日", "2013-01-01T00:00:00.00+09:00", "2013-01-02T00:00:00.00+09:00"],
|
55
|
+
["銀行休業日", "2013-01-02T00:00:00.00+09:00", "2013-01-03T00:00:00.00+09:00"],
|
56
|
+
["銀行休業日", "2013-01-03T00:00:00.00+09:00", "2013-01-04T00:00:00.00+09:00"],
|
57
|
+
["成人の日", "2013-01-14T00:00:00.00+09:00", "2013-01-15T00:00:00.00+09:00"],
|
58
|
+
["建国記念の日", "2013-02-11T00:00:00.00+09:00", "2013-02-12T00:00:00.00+09:00"],
|
59
|
+
["春分の日", "2013-03-20T00:00:00.00+09:00", "2013-03-21T00:00:00.00+09:00"],
|
60
|
+
["昭和の日", "2013-04-29T00:00:00.00+09:00", "2013-04-30T00:00:00.00+09:00"],
|
61
|
+
["憲法記念日", "2013-05-03T00:00:00.00+09:00", "2013-05-04T00:00:00.00+09:00"],
|
62
|
+
["みどりの日", "2013-05-04T00:00:00.00+09:00", "2013-05-05T00:00:00.00+09:00"],
|
63
|
+
["こどもの日", "2013-05-05T00:00:00.00+09:00", "2013-05-06T00:00:00.00+09:00"],
|
64
|
+
["こどもの日 振替休日", "2013-05-06T00:00:00.00+09:00", "2013-05-07T00:00:00.00+09:00"],
|
65
|
+
["海の日", "2013-07-15T00:00:00.00+09:00", "2013-07-16T00:00:00.00+09:00"],
|
66
|
+
["敬老の日", "2013-09-16T00:00:00.00+09:00", "2013-09-17T00:00:00.00+09:00"],
|
67
|
+
["秋分の日", "2013-09-23T00:00:00.00+09:00", "2013-09-24T00:00:00.00+09:00"],
|
68
|
+
["体育の日", "2013-10-14T00:00:00.00+09:00", "2013-10-15T00:00:00.00+09:00"],
|
69
|
+
["文化の日", "2013-11-03T00:00:00.00+09:00", "2013-11-04T00:00:00.00+09:00"],
|
70
|
+
["文化の日 振替休日", "2013-11-04T00:00:00.00+09:00", "2013-11-05T00:00:00.00+09:00"],
|
71
|
+
["勤労感謝の日", "2013-11-23T00:00:00.00+09:00", "2013-11-24T00:00:00.00+09:00"],
|
72
|
+
["天皇誕生日", "2013-12-23T00:00:00.00+09:00", "2013-12-24T00:00:00.00+09:00"],
|
73
|
+
["クリスマス", "2013-12-25T00:00:00.00+09:00", "2013-12-26T00:00:00.00+09:00"],
|
74
|
+
["大晦日", "2013-12-31T00:00:00.00+09:00", "2014-01-01T00:00:00.00+09:00"]
|
75
|
+
]
|
76
|
+
|
77
|
+
HOLIDAYS2 = [ # Private Feed
|
78
|
+
["元日", "2013-01-01T00:00:00.00+09:00", "2013-01-02T00:00:00.00+09:00"],
|
79
|
+
["元日 振替休日", "2013-01-02T00:00:00.00+09:00", "2013-01-03T00:00:00.00+09:00"],
|
80
|
+
["銀行休業日", "2013-01-03T00:00:00.00+09:00", "2013-01-04T00:00:00.00+09:00"],
|
81
|
+
["成人の日", "2013-01-14T00:00:00.00+09:00", "2013-01-15T00:00:00.00+09:00"],
|
82
|
+
["建国記念の日", "2013-02-11T00:00:00.00+09:00", "2013-02-12T00:00:00.00+09:00"],
|
83
|
+
["春分の日", "2013-03-20T00:00:00.00+09:00", "2013-03-21T00:00:00.00+09:00"],
|
84
|
+
["昭和の日", "2013-04-29T00:00:00.00+09:00", "2013-04-30T00:00:00.00+09:00"],
|
85
|
+
["憲法記念日", "2013-05-03T00:00:00.00+09:00", "2013-05-04T00:00:00.00+09:00"],
|
86
|
+
["みどりの日", "2013-05-04T00:00:00.00+09:00", "2013-05-05T00:00:00.00+09:00"],
|
87
|
+
["こどもの日", "2013-05-05T00:00:00.00+09:00", "2013-05-06T00:00:00.00+09:00"],
|
88
|
+
["みどりの日 振替休日", "2013-05-06T00:00:00.00+09:00", "2013-05-07T00:00:00.00+09:00"],
|
89
|
+
["海の日", "2013-07-15T00:00:00.00+09:00", "2013-07-16T00:00:00.00+09:00"],
|
90
|
+
["敬老の日", "2013-09-16T00:00:00.00+09:00", "2013-09-17T00:00:00.00+09:00"],
|
91
|
+
["秋分の日", "2013-09-23T00:00:00.00+09:00", "2013-09-24T00:00:00.00+09:00"],
|
92
|
+
["体育の日", "2013-10-14T00:00:00.00+09:00", "2013-10-15T00:00:00.00+09:00"],
|
93
|
+
["文化の日", "2013-11-03T00:00:00.00+09:00", "2013-11-04T00:00:00.00+09:00"],
|
94
|
+
["文化の日 振替休日", "2013-11-04T00:00:00.00+09:00", "2013-11-05T00:00:00.00+09:00"],
|
95
|
+
["勤労感謝の日", "2013-11-23T00:00:00.00+09:00", "2013-11-24T00:00:00.00+09:00"],
|
96
|
+
["天皇誕生日", "2013-12-23T00:00:00.00+09:00", "2013-12-24T00:00:00.00+09:00"],
|
97
|
+
["クリスマス", "2013-12-25T00:00:00.00+09:00", "2013-12-26T00:00:00.00+09:00"],
|
98
|
+
["大晦日", "2013-12-31T00:00:00.00+09:00", "2014-01-01T00:00:00.00+09:00"]
|
99
|
+
]
|
100
|
+
|
101
|
+
WEEKLY_EVENTS = [
|
102
|
+
"2014-07-17T08:30:00+09:00...2014-07-17T09:30:00+09:00",
|
103
|
+
"2014-07-31T08:30:00+09:00...2014-07-31T09:30:00+09:00"
|
104
|
+
]
|
105
|
+
|
106
|
+
def get_cal(feed)
|
107
|
+
::GoogleCalendar::Calendar::new(::GoogleCalendar::Service.new("#{ACCOUNT}@gmail.com", PASSWORD), feed)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_nothing
|
111
|
+
end
|
112
|
+
|
113
|
+
if const_defined?(:PASSWORD) && Object.const_defined?(:GoogleCalendar)
|
114
|
+
|
115
|
+
def test__to_vevent
|
116
|
+
holidays = HOLIDAYS1.dup
|
117
|
+
gcal = get_cal(PUBLIC_FEED % ['japanese', 'ja'])
|
118
|
+
gcal.events({'start-min'=>'2013-01-01', 'start-max'=>'2014-01-01',
|
119
|
+
'orderby'=>'starttime', 'sortorder'=>'a' # a:asend, d:desend
|
120
|
+
}).each do |event|
|
121
|
+
vevent = event.to_vevent
|
122
|
+
assert_equal(holidays.shift, [vevent.summary, vevent.dtstart.to_s, vevent.dtend.to_s])
|
123
|
+
# puts event.xml
|
124
|
+
end
|
125
|
+
assert_equal(0, holidays.size)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test__to_gcalevent
|
129
|
+
gcal = get_cal(PRIVATE_FEED % ACCOUNT)
|
130
|
+
period = {'start-min'=>'2001-01-01', 'start-max'=>'2001-01-31'}
|
131
|
+
gcal.events(period).each do |event|
|
132
|
+
event.destroy
|
133
|
+
end
|
134
|
+
event = When.Resource("examples/JapanHolidays.ics::Ganjitsu").to_gcalevent(gcal)
|
135
|
+
event.save!
|
136
|
+
holidays = [RULE0]
|
137
|
+
gcal.events(period).each do |event|
|
138
|
+
assert_equal(holidays.shift, event.recurrence)
|
139
|
+
end
|
140
|
+
assert_equal(0, holidays.size)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test__enum_for
|
144
|
+
holidays = HOLIDAYS2.dup
|
145
|
+
gcal = get_cal(PUBLIC_FEED % ['japanese', 'ja'])
|
146
|
+
gcal.enum_for({'start-min'=>'2013-01-01', 'start-max'=>'2014-01-01'}).each do |date|
|
147
|
+
sample = holidays.shift
|
148
|
+
assert_equal(sample[1] + '...' + sample[2], date.to_s)
|
149
|
+
end
|
150
|
+
assert_equal(0, holidays.size)
|
151
|
+
end
|
152
|
+
=begin
|
153
|
+
def test__private_events_1
|
154
|
+
weekly_events = WEEKLY_EVENTS.dup
|
155
|
+
gcal = get_cal(PRIVATE_FEED % ACCOUNT)
|
156
|
+
period = {'start-min'=>'2014-07-01', 'start-max'=>'2014-08-01'}
|
157
|
+
|
158
|
+
assert_equal(["canceled","confirmed"], gcal.events(period).map {|event| event.event_status})
|
159
|
+
gcal.enum_for(period).each do |date|
|
160
|
+
assert_equal(weekly_events.shift, date.to_s)
|
161
|
+
end
|
162
|
+
assert_equal(0, weekly_events.size)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test__private_events_2
|
166
|
+
gcal = get_cal(PRIVATE_FEED % ACCOUNT)
|
167
|
+
period = {'start-min'=>YEAR + '-03-01', 'start-max'=>YEAR + '-03-31'}
|
168
|
+
|
169
|
+
gcal.events(period).each do |event|
|
170
|
+
event.destroy
|
171
|
+
end
|
172
|
+
|
173
|
+
new_event = gcal.create_event
|
174
|
+
new_event.title = "MiniTest Event"
|
175
|
+
new_event.desc = "MiniTest Event Description"
|
176
|
+
new_event.where = "America/New_York"
|
177
|
+
#new_event.st = Time.mktime(YEAR.to_i, 3, 21, 12, 0, 0)
|
178
|
+
#new_event.en = Time.mktime(YEAR.to_i, 3, 22, 13, 0, 0)
|
179
|
+
new_event.recurrence = RULE1
|
180
|
+
new_event.save!
|
181
|
+
|
182
|
+
gcal.events(period).each do |event|
|
183
|
+
assert_equal([new_event.title, new_event.desc, new_event.where, RECURRENCE],
|
184
|
+
[event.title, event.desc, event.where, event.recurrence])
|
185
|
+
end
|
186
|
+
new_event.destroy
|
187
|
+
end
|
188
|
+
=end
|
189
|
+
else
|
190
|
+
puts "Tests for GoogleCalendar have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|