vanadiel-time 0.1.0
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.
- data/.document +3 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +4 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +47 -0
- data/Rakefile +34 -0
- data/examples/clock.rb +12 -0
- data/lib/vanadiel/day.rb +29 -0
- data/lib/vanadiel/moon.rb +91 -0
- data/lib/vanadiel/time.rb +533 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/time_spec.rb +682 -0
- data/vanadiel-time.gemspec +26 -0
- metadata +149 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
# class Time
|
4
|
+
# # Convert timezone
|
5
|
+
# # from "Ruby Cookbook"
|
6
|
+
# def convert_zone(to_zone)
|
7
|
+
# original_zone = ENV["TZ"]
|
8
|
+
# utc_time = dup.gmtime
|
9
|
+
# ENV["TZ"] = to_zone
|
10
|
+
# to_zone_time = utc_time.localtime
|
11
|
+
# ENV["TZ"] = original_zone
|
12
|
+
# return to_zone_time
|
13
|
+
# end
|
14
|
+
# end
|
data/spec/time_spec.rb
ADDED
@@ -0,0 +1,682 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'vanadiel/time'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
describe Vanadiel::Time do
|
8
|
+
it "should have a VERSION constant" do
|
9
|
+
subject.class.const_get('VERSION').should_not be_empty
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Vanadiel::Time, '.earth_to_vana' do
|
14
|
+
context 'with argument -91270800000000' do
|
15
|
+
it 'should return 0' do
|
16
|
+
Vanadiel::Time.earth_to_vana(-91270800000000).should == 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Vanadiel::Time, '.vana_to_earth' do
|
22
|
+
context 'with argument 0' do
|
23
|
+
it 'should return -91270800000000' do
|
24
|
+
Vanadiel::Time.vana_to_earth(0).should == -91270800000000
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
share_examples_for 'Vanadiel::Time with no argument' do
|
30
|
+
before do
|
31
|
+
@time_now = Time.local(2002, 1, 1, 12, 34, 56)
|
32
|
+
Time.stub!(:now).and_return(@time_now)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should create current time object" do
|
36
|
+
subject.to_earth_time.to_f.round(6).should == @time_now.to_f.round(6)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
shared_examples 'YMDHMS constructor' do |ctor|
|
41
|
+
# A.D. 1967/02/10 00:00:00 JST
|
42
|
+
# C.E. 0001/01/01 00:00:00
|
43
|
+
context 'with arguments (1, 1, 1, 0, 0, 0)' do
|
44
|
+
subject { Vanadiel::Time.send(ctor, 1, 1, 1, 0, 0, 0) }
|
45
|
+
it 'should create Vana\'diel time "0001/01/01 00:00:00"' do
|
46
|
+
subject.to_earth_time.should == Time.iso8601('1967-02-10T00:00:00+09:00')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# A.D. 2002/01/01(Tue) 00:00:00 JST
|
51
|
+
# C.E. 0886/01/01(Fir) 00:00:00
|
52
|
+
context 'with arguments (886, 1, 1, 0, 0, 0)' do
|
53
|
+
subject { Vanadiel::Time.send(ctor, 886, 1, 1, 0, 0, 0) }
|
54
|
+
it 'should create Vana\'diel time "0886/01/01 00:00:00"' do
|
55
|
+
subject.to_earth_time.should == Time.iso8601('2002-01-01T00:00:00+09:00')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# A.D. 2047/10/22(Tue) 01:00:00 JST
|
60
|
+
# C.E. 2047/10/22(Wat) 01:00:00
|
61
|
+
context 'with arguments (2047, 10, 22, 1, 0, 0)' do
|
62
|
+
subject { Vanadiel::Time.send(ctor, 2047, 10, 22, 1, 0, 0) }
|
63
|
+
it 'should create Vana\'diel time "2047/10/22 01:00:00"' do
|
64
|
+
subject.to_earth_time.should == Time.iso8601('2047-10-22T01:00:00+09:00')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# A.D. 2047/10/21(Mon) 15:37:30 UTC
|
69
|
+
# C.E. 2047/10/21(Win) 15:37:30
|
70
|
+
context 'with arguments (2047, 10, 21, 15, 37, 30)' do
|
71
|
+
subject { Vanadiel::Time.send(ctor, 2047, 10, 21, 15, 37, 30) }
|
72
|
+
it 'should create Vana\'diel time "2047/10/21 15:37:30"' do
|
73
|
+
subject.to_earth_time.should == Time.gm(2047, 10, 21, 15, 37, 30)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with arguments (1, 1, 1, 0, 0, 0, 0)' do
|
78
|
+
subject { Vanadiel::Time.send(ctor, 1, 1, 1, 0, 0, 0, 0) }
|
79
|
+
it 'should create Vana\'diel time "1/01/01 00:00:00"' do
|
80
|
+
subject.to_f.should == 0
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with arguments (1, 1, 1, 0, 0, 0, 999999)' do
|
85
|
+
subject { Vanadiel::Time.send(ctor, 1, 1, 1, 0, 0, 0, 999999) }
|
86
|
+
it 'should create Vana\'diel time "1/01/01 00:00:00.999999"' do
|
87
|
+
subject.to_f.should == 0.999999
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe Vanadiel::Time, '.new' do
|
93
|
+
include_examples 'YMDHMS constructor', :new
|
94
|
+
|
95
|
+
context 'with no argument' do
|
96
|
+
subject { Vanadiel::Time.new }
|
97
|
+
it_should_behave_like 'Vanadiel::Time with no argument'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe Vanadiel::Time, '.now' do
|
102
|
+
describe '.now' do
|
103
|
+
subject { Vanadiel::Time.now }
|
104
|
+
it_should_behave_like 'Vanadiel::Time with no argument'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe Vanadiel::Time, '.mktime' do
|
109
|
+
include_examples 'YMDHMS constructor', :mktime
|
110
|
+
|
111
|
+
context 'with no argument' do
|
112
|
+
subject { Vanadiel::Time.new }
|
113
|
+
it "should raise ArgumentError" do
|
114
|
+
expect { Vanadiel::Time.mktime }.to raise_error(ArgumentError)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe Vanadiel::Time, '.at' do
|
120
|
+
before do
|
121
|
+
@vana_time = Vanadiel::Time.mktime(886, 1, 1, 0, 0, 0)
|
122
|
+
@vana_time_frac = Vanadiel::Time.mktime(886, 1, 1, 0, 0, 0, 120000)
|
123
|
+
@earth_time = Time.now
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'with argument Vanadiel::Time' do
|
127
|
+
subject { Vanadiel::Time.at(@vana_time) }
|
128
|
+
it "should create Vana'diel time with passed time" do
|
129
|
+
subject.to_f.round(6).should == @vana_time.to_f.round(6)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'with argument Time' do
|
134
|
+
subject { Vanadiel::Time.at(@earth_time) }
|
135
|
+
it "should create Vana'diel time with passed time" do
|
136
|
+
subject.to_earth_time.to_f.round(6).should == @earth_time.to_f.round(6)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'with argument Integer' do
|
141
|
+
subject { Vanadiel::Time.at(@vana_time.to_i) }
|
142
|
+
it "should create Vana'diel time with passed time as Vana'diel time" do
|
143
|
+
subject.to_f.round(6).should == @vana_time.to_f.round(6)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'with argument Integer and usec fraction' do
|
148
|
+
subject { Vanadiel::Time.at(@vana_time.to_i, 120000) }
|
149
|
+
it "should create Vana'diel time with passed time as Vana'diel time" do
|
150
|
+
subject.to_f.round(6).should == @vana_time_frac.to_f.round(6)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with argument Float' do
|
155
|
+
subject { Vanadiel::Time.at(@vana_time.to_f) }
|
156
|
+
it "should create Vana'diel time with passed time as Vana'diel time" do
|
157
|
+
subject.to_f.round(6).should == @vana_time.to_f.round(6)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'with argument Float and usec fraction' do
|
162
|
+
subject { Vanadiel::Time.at(@vana_time.to_f, 120000) }
|
163
|
+
it "should create Vana'diel time with passed time as Vana'diel time" do
|
164
|
+
subject.to_f.round(6).should == @vana_time_frac.to_f.round(6)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'with argument "foo"' do
|
169
|
+
it "should raise ArgumentError" do
|
170
|
+
expect { Vanadiel::Time.at('foo') }.to raise_error(ArgumentError)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe 'Vanadiel::Time properties' do
|
176
|
+
share_examples_for "time object which has each part property" do
|
177
|
+
its(:year) { should == @year }
|
178
|
+
its(:month) { should == @mon }
|
179
|
+
its(:mon) { should == @mon }
|
180
|
+
its(:mday) { should == @day }
|
181
|
+
its(:day) { should == @day }
|
182
|
+
its(:hour) { should == @hour }
|
183
|
+
its(:min) { should == @min }
|
184
|
+
its(:sec) { should == @sec }
|
185
|
+
its(:usec) { should == @usec }
|
186
|
+
its(:wday) { should == @wday }
|
187
|
+
its(:yday) { should == @yday }
|
188
|
+
its(:moon_age) { should == @moon_age }
|
189
|
+
its(:moon_age7) { should == @moon_age7 }
|
190
|
+
its(:time_of_moon) { should == @time_of_moon }
|
191
|
+
end
|
192
|
+
|
193
|
+
context 'with C.E. 887/04/21 12:34:56' do
|
194
|
+
before do
|
195
|
+
@year = 887; @mon = 4; @day = 21
|
196
|
+
@hour = 12; @min = 34; @sec = 56; @usec = 123456
|
197
|
+
@wday = 6; @yday = 111; @moon_age = 7; @moon_age7 = 5; @time_of_moon = 131696123456
|
198
|
+
end
|
199
|
+
|
200
|
+
subject { Vanadiel::Time.new(@year, @mon, @day, @hour, @min, @sec, @usec) }
|
201
|
+
|
202
|
+
it_should_behave_like "time object which has each part property"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe Vanadiel::Time, '#moon_percent' do
|
207
|
+
patterns = [
|
208
|
+
{ 'vana_time' => Vanadiel::Time.new( 1, 1, 1), 'moon_age' => 1, 'moon_age7' => 1, 'moon_percent' => 19 },
|
209
|
+
{ 'vana_time' => Vanadiel::Time.new( 886, 1, 1), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 10 },
|
210
|
+
|
211
|
+
# 二十六夜 12%(Waning Crescent Moon)
|
212
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 18, 23, 59, 59, 999999), 'moon_age' => 11, 'moon_age7' => 7, 'moon_percent' => 12 },
|
213
|
+
# 新月 10%(New Moon)
|
214
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 19), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 10 },
|
215
|
+
# 新月 10%(New Moon)
|
216
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 19, 23, 59, 59, 999999), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 10 },
|
217
|
+
# 新月 7%(New Moon)
|
218
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 20), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 7 },
|
219
|
+
# 新月 5%(New Moon)
|
220
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 21), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 5 },
|
221
|
+
# 新月 2%(New Moon)
|
222
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 22), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 2 },
|
223
|
+
# 新月 2%(New Moon)
|
224
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 22, 23, 59, 59, 999999), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 2 },
|
225
|
+
# 新月 0%(New Moon)
|
226
|
+
{ 'vana_time' => Vanadiel::Time.new(1155, 12, 23), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 0 },
|
227
|
+
|
228
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 2), 'moon_age' => 1, 'moon_age7' => 1, 'moon_percent' => 21 },
|
229
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 3), 'moon_age' => 2, 'moon_age7' => 1, 'moon_percent' => 24 },
|
230
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 9), 'moon_age' => 2, 'moon_age7' => 1, 'moon_percent' => 38 },
|
231
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 10), 'moon_age' => 3, 'moon_age7' => 2, 'moon_percent' => 40 },
|
232
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 16), 'moon_age' => 3, 'moon_age7' => 2, 'moon_percent' => 55 },
|
233
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 17), 'moon_age' => 4, 'moon_age7' => 3, 'moon_percent' => 57 },
|
234
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 23), 'moon_age' => 4, 'moon_age7' => 3, 'moon_percent' => 71 },
|
235
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 24), 'moon_age' => 5, 'moon_age7' => 3, 'moon_percent' => 74 },
|
236
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 1, 30), 'moon_age' => 5, 'moon_age7' => 3, 'moon_percent' => 88 },
|
237
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 1), 'moon_age' => 6, 'moon_age7' => 4, 'moon_percent' => 90 },
|
238
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 5), 'moon_age' => 6, 'moon_age7' => 4, 'moon_percent' => 100 },
|
239
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 7), 'moon_age' => 6, 'moon_age7' => 4, 'moon_percent' => 95 },
|
240
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 8), 'moon_age' => 7, 'moon_age7' => 5, 'moon_percent' => 93 },
|
241
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 14), 'moon_age' => 7, 'moon_age7' => 5, 'moon_percent' => 79 },
|
242
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 15), 'moon_age' => 8, 'moon_age7' => 5, 'moon_percent' => 76 },
|
243
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 21), 'moon_age' => 8, 'moon_age7' => 5, 'moon_percent' => 62 },
|
244
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 22), 'moon_age' => 9, 'moon_age7' => 6, 'moon_percent' => 60 },
|
245
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 28), 'moon_age' => 9, 'moon_age7' => 6, 'moon_percent' => 45 },
|
246
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 2, 29), 'moon_age' => 10, 'moon_age7' => 7, 'moon_percent' => 43 },
|
247
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 5), 'moon_age' => 10, 'moon_age7' => 7, 'moon_percent' => 29 },
|
248
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 6), 'moon_age' => 11, 'moon_age7' => 7, 'moon_percent' => 26 },
|
249
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 12), 'moon_age' => 11, 'moon_age7' => 7, 'moon_percent' => 12 },
|
250
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 13), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 10 },
|
251
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 17), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 0 },
|
252
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 19), 'moon_age' => 0, 'moon_age7' => 0, 'moon_percent' => 5 },
|
253
|
+
{ 'vana_time' => Vanadiel::Time.new(1156, 3, 20), 'moon_age' => 1, 'moon_age7' => 1, 'moon_percent' => 7 },
|
254
|
+
]
|
255
|
+
|
256
|
+
patterns.each {|p|
|
257
|
+
context "with C.E. #{p['vana_time'].strftime('%F %T.%N')}" do
|
258
|
+
subject { p['vana_time'] }
|
259
|
+
its(:moon_age) { should == p['moon_age'] }
|
260
|
+
its(:moon_age12) { should == p['moon_age'] }
|
261
|
+
its(:moon_age7) { should == p['moon_age7'] }
|
262
|
+
its(:moon_percent) { should == p['moon_percent'] }
|
263
|
+
end
|
264
|
+
}
|
265
|
+
|
266
|
+
# 1155/12/18 00:00:00 二十六夜 12%(Waning Crescent Moon)
|
267
|
+
# 1155/12/19 00:00:00 新月 10%(New Moon)
|
268
|
+
# 1155/12/20 00:00:00 新月 7%(New Moon)
|
269
|
+
# 1155/12/21 00:00:00 新月 5%(New Moon)
|
270
|
+
# 1155/12/22 00:00:00 新月 2%(New Moon)
|
271
|
+
# 1155/12/23 00:00:00 新月 0%(New Moon)
|
272
|
+
# 1155/12/24 00:00:00 新月 2%(New Moon)
|
273
|
+
# 1155/12/25 00:00:00 新月 5%(New Moon)
|
274
|
+
# 1155/12/26 00:00:00 三日月 7%(Waxing Crescent Moon)
|
275
|
+
# 1155/12/27 00:00:00 三日月 10%(Waxing Crescent Moon)
|
276
|
+
# 1155/12/28 00:00:00 三日月 12%(Waxing Crescent Moon)
|
277
|
+
# 1155/12/29 00:00:00 三日月 14%(Waxing Crescent Moon)
|
278
|
+
# 1155/12/30 00:00:00 三日月 17%(Waxing Crescent Moon)
|
279
|
+
# 1156/01/01 00:00:00 三日月 19%(Waxing Crescent Moon)
|
280
|
+
# 1156/01/02 00:00:00 三日月 21%(Waxing Crescent Moon)
|
281
|
+
# 1156/01/03 00:00:00 七日月 24%(Waxing Crescent Moon)
|
282
|
+
# 1156/01/04 00:00:00 七日月 26%(Waxing Crescent Moon)
|
283
|
+
# 1156/01/05 00:00:00 七日月 29%(Waxing Crescent Moon)
|
284
|
+
# 1156/01/06 00:00:00 七日月 31%(Waxing Crescent Moon)
|
285
|
+
# 1156/01/07 00:00:00 七日月 33%(Waxing Crescent Moon)
|
286
|
+
# 1156/01/08 00:00:00 七日月 36%(Waxing Crescent Moon)
|
287
|
+
# 1156/01/09 00:00:00 七日月 38%(Waxing Crescent Moon)
|
288
|
+
# 1156/01/10 00:00:00 上弦の月 40%(First Quarter Moon)
|
289
|
+
# 1156/01/11 00:00:00 上弦の月 43%(First Quarter Moon)
|
290
|
+
# 1156/01/12 00:00:00 上弦の月 45%(First Quarter Moon)
|
291
|
+
# 1156/01/13 00:00:00 上弦の月 48%(First Quarter Moon)
|
292
|
+
# 1156/01/14 00:00:00 上弦の月 50%(First Quarter Moon)
|
293
|
+
# 1156/01/15 00:00:00 上弦の月 52%(First Quarter Moon)
|
294
|
+
# 1156/01/16 00:00:00 上弦の月 55%(First Quarter Moon)
|
295
|
+
# 1156/01/17 00:00:00 十日夜 57%(Waxing Gibbous Moon)
|
296
|
+
# 1156/01/18 00:00:00 十日夜 60%(Waxing Gibbous Moon)
|
297
|
+
# 1156/01/19 00:00:00 十日夜 62%(Waxing Gibbous Moon)
|
298
|
+
# 1156/01/20 00:00:00 十日夜 64%(Waxing Gibbous Moon)
|
299
|
+
# 1156/01/21 00:00:00 十日夜 67%(Waxing Gibbous Moon)
|
300
|
+
# 1156/01/22 00:00:00 十日夜 69%(Waxing Gibbous Moon)
|
301
|
+
# 1156/01/23 00:00:00 十日夜 71%(Waxing Gibbous Moon)
|
302
|
+
# 1156/01/24 00:00:00 十三夜 74%(Waxing Gibbous Moon)
|
303
|
+
# 1156/01/25 00:00:00 十三夜 76%(Waxing Gibbous Moon)
|
304
|
+
# 1156/01/26 00:00:00 十三夜 79%(Waxing Gibbous Moon)
|
305
|
+
# 1156/01/27 00:00:00 十三夜 81%(Waxing Gibbous Moon)
|
306
|
+
# 1156/01/28 00:00:00 十三夜 83%(Waxing Gibbous Moon)
|
307
|
+
# 1156/01/29 00:00:00 十三夜 86%(Waxing Gibbous Moon)
|
308
|
+
# 1156/01/30 00:00:00 十三夜 88%(Waxing Gibbous Moon)
|
309
|
+
# 1156/02/01 00:00:00 満月 90%(Full Moon)
|
310
|
+
# 1156/02/02 00:00:00 満月 93%(Full Moon)
|
311
|
+
# 1156/02/03 00:00:00 満月 95%(Full Moon)
|
312
|
+
# 1156/02/04 00:00:00 満月 98%(Full Moon)
|
313
|
+
# 1156/02/05 00:00:00 満月 100%(Full Moon)
|
314
|
+
# 1156/02/06 00:00:00 満月 98%(Full Moon)
|
315
|
+
# 1156/02/07 00:00:00 満月 95%(Full Moon)
|
316
|
+
# 1156/02/08 00:00:00 十六夜 93%(Waning Gibbous Moon)
|
317
|
+
# 1156/02/09 00:00:00 十六夜 90%(Waning Gibbous Moon)
|
318
|
+
# 1156/02/10 00:00:00 十六夜 88%(Waning Gibbous Moon)
|
319
|
+
# 1156/02/11 00:00:00 十六夜 86%(Waning Gibbous Moon)
|
320
|
+
# 1156/02/12 00:00:00 十六夜 83%(Waning Gibbous Moon)
|
321
|
+
# 1156/02/13 00:00:00 十六夜 81%(Waning Gibbous Moon)
|
322
|
+
# 1156/02/14 00:00:00 十六夜 79%(Waning Gibbous Moon)
|
323
|
+
# 1156/02/15 00:00:00 居待月 76%(Waning Gibbous Moon)
|
324
|
+
# 1156/02/16 00:00:00 居待月 74%(Waning Gibbous Moon)
|
325
|
+
# 1156/02/17 00:00:00 居待月 71%(Waning Gibbous Moon)
|
326
|
+
# 1156/02/18 00:00:00 居待月 69%(Waning Gibbous Moon)
|
327
|
+
# 1156/02/19 00:00:00 居待月 67%(Waning Gibbous Moon)
|
328
|
+
# 1156/02/20 00:00:00 居待月 64%(Waning Gibbous Moon)
|
329
|
+
# 1156/02/21 00:00:00 居待月 62%(Waning Gibbous Moon)
|
330
|
+
# 1156/02/22 00:00:00 下弦の月 60%(Last Quarter Moon)
|
331
|
+
# 1156/02/23 00:00:00 下弦の月 57%(Last Quarter Moon)
|
332
|
+
# 1156/02/24 00:00:00 下弦の月 55%(Last Quarter Moon)
|
333
|
+
# 1156/02/25 00:00:00 下弦の月 52%(Last Quarter Moon)
|
334
|
+
# 1156/02/26 00:00:00 下弦の月 50%(Last Quarter Moon)
|
335
|
+
# 1156/02/27 00:00:00 下弦の月 48%(Last Quarter Moon)
|
336
|
+
# 1156/02/28 00:00:00 下弦の月 45%(Last Quarter Moon)
|
337
|
+
# 1156/02/29 00:00:00 二十日余月 43%(Waning Crescent Moon)
|
338
|
+
# 1156/02/30 00:00:00 二十日余月 40%(Waning Crescent Moon)
|
339
|
+
# 1156/03/01 00:00:00 二十日余月 38%(Waning Crescent Moon)
|
340
|
+
# 1156/03/02 00:00:00 二十日余月 36%(Waning Crescent Moon)
|
341
|
+
# 1156/03/03 00:00:00 二十日余月 33%(Waning Crescent Moon)
|
342
|
+
# 1156/03/04 00:00:00 二十日余月 31%(Waning Crescent Moon)
|
343
|
+
# 1156/03/05 00:00:00 二十日余月 29%(Waning Crescent Moon)
|
344
|
+
# 1156/03/06 00:00:00 二十六夜 26%(Waning Crescent Moon)
|
345
|
+
# 1156/03/07 00:00:00 二十六夜 24%(Waning Crescent Moon)
|
346
|
+
# 1156/03/08 00:00:00 二十六夜 21%(Waning Crescent Moon)
|
347
|
+
# 1156/03/09 00:00:00 二十六夜 19%(Waning Crescent Moon)
|
348
|
+
# 1156/03/10 00:00:00 二十六夜 17%(Waning Crescent Moon)
|
349
|
+
# 1156/03/11 00:00:00 二十六夜 14%(Waning Crescent Moon)
|
350
|
+
# 1156/03/12 00:00:00 二十六夜 12%(Waning Crescent Moon)
|
351
|
+
# 1156/03/13 00:00:00 新月 10%(New Moon)
|
352
|
+
# 1156/03/14 00:00:00 新月 7%(New Moon)
|
353
|
+
# 1156/03/15 00:00:00 新月 5%(New Moon)
|
354
|
+
# 1156/03/16 00:00:00 新月 2%(New Moon)
|
355
|
+
# 1156/03/17 00:00:00 新月 0%(New Moon)
|
356
|
+
# 1156/03/18 00:00:00 新月 2%(New Moon)
|
357
|
+
# 1156/03/19 00:00:00 新月 5%(New Moon)
|
358
|
+
# 1156/03/20 00:00:00 三日月 7%(Waxing Crescent Moon)
|
359
|
+
# 1156/03/21 00:00:00 三日月 10%(Waxing Crescent Moon)
|
360
|
+
# 1156/03/22 00:00:00 三日月 12%(Waxing Crescent Moon)
|
361
|
+
# 1156/03/23 00:00:00 三日月 14%(Waxing Crescent Moon)
|
362
|
+
# 1156/03/24 00:00:00 三日月 17%(Waxing Crescent Moon)
|
363
|
+
# 1156/03/25 00:00:00 三日月 19%(Waxing Crescent Moon)
|
364
|
+
# 1156/03/26 00:00:00 三日月 21%(Waxing Crescent Moon)
|
365
|
+
# 1156/03/27 00:00:00 七日月 24%(Waxing Crescent Moon)
|
366
|
+
# 1156/03/28 00:00:00 七日月 26%(Waxing Crescent Moon)
|
367
|
+
# 1156/03/29 00:00:00 七日月 29%(Waxing Crescent Moon)
|
368
|
+
# 1156/03/30 00:00:00 七日月 31%(Waxing Crescent Moon)
|
369
|
+
# 1156/04/01 00:00:00 七日月 33%(Waxing Crescent Moon)
|
370
|
+
# 1156/04/02 00:00:00 七日月 36%(Waxing Crescent Moon)
|
371
|
+
# 1156/04/03 00:00:00 七日月 38%(Waxing Crescent Moon)
|
372
|
+
# 1156/04/04 00:00:00 上弦の月 40%(First Quarter Moon)
|
373
|
+
end
|
374
|
+
|
375
|
+
shared_context 'Vanadiel::Time with arguments(2047, 10, 21, 15, 37, 30, 123456)' do
|
376
|
+
let(:vana_time) { Vanadiel::Time.new(2047, 10, 21, 15, 37, 30, 123456) }
|
377
|
+
end
|
378
|
+
|
379
|
+
describe Vanadiel::Time, ' weekday methods' do
|
380
|
+
context 'when C.E. 1000-01-01' do
|
381
|
+
subject { Vanadiel::Time.new(1000, 1, 1) }
|
382
|
+
it { should be_firesday }
|
383
|
+
it { should_not be_earthsday }
|
384
|
+
it { should_not be_watersday }
|
385
|
+
it { should_not be_windsday }
|
386
|
+
it { should_not be_iceday }
|
387
|
+
it { should_not be_lightningday }
|
388
|
+
it { should_not be_lightsday }
|
389
|
+
it { should_not be_darksday }
|
390
|
+
end
|
391
|
+
|
392
|
+
context 'when C.E. 1000-01-02' do
|
393
|
+
subject { Vanadiel::Time.new(1000, 1, 2) }
|
394
|
+
it { should_not be_firesday }
|
395
|
+
it { should be_earthsday }
|
396
|
+
it { should_not be_watersday }
|
397
|
+
it { should_not be_windsday }
|
398
|
+
it { should_not be_iceday }
|
399
|
+
it { should_not be_lightningday }
|
400
|
+
it { should_not be_lightsday }
|
401
|
+
it { should_not be_darksday }
|
402
|
+
end
|
403
|
+
|
404
|
+
context 'when C.E. 1000-01-03' do
|
405
|
+
subject { Vanadiel::Time.new(1000, 1, 3) }
|
406
|
+
it { should_not be_firesday }
|
407
|
+
it { should_not be_earthsday }
|
408
|
+
it { should be_watersday }
|
409
|
+
it { should_not be_windsday }
|
410
|
+
it { should_not be_iceday }
|
411
|
+
it { should_not be_lightningday }
|
412
|
+
it { should_not be_lightsday }
|
413
|
+
it { should_not be_darksday }
|
414
|
+
end
|
415
|
+
|
416
|
+
context 'when C.E. 1000-01-04' do
|
417
|
+
subject { Vanadiel::Time.new(1000, 1, 4) }
|
418
|
+
it { should_not be_firesday }
|
419
|
+
it { should_not be_earthsday }
|
420
|
+
it { should_not be_watersday }
|
421
|
+
it { should be_windsday }
|
422
|
+
it { should_not be_iceday }
|
423
|
+
it { should_not be_lightningday }
|
424
|
+
it { should_not be_lightsday }
|
425
|
+
it { should_not be_darksday }
|
426
|
+
end
|
427
|
+
|
428
|
+
context 'when C.E. 1000-01-05' do
|
429
|
+
subject { Vanadiel::Time.new(1000, 1, 5) }
|
430
|
+
it { should_not be_firesday }
|
431
|
+
it { should_not be_earthsday }
|
432
|
+
it { should_not be_watersday }
|
433
|
+
it { should_not be_windsday }
|
434
|
+
it { should be_iceday }
|
435
|
+
it { should_not be_lightningday }
|
436
|
+
it { should_not be_lightsday }
|
437
|
+
it { should_not be_darksday }
|
438
|
+
end
|
439
|
+
|
440
|
+
context 'when C.E. 1000-01-06' do
|
441
|
+
subject { Vanadiel::Time.new(1000, 1, 6) }
|
442
|
+
it { should_not be_firesday }
|
443
|
+
it { should_not be_earthsday }
|
444
|
+
it { should_not be_watersday }
|
445
|
+
it { should_not be_windsday }
|
446
|
+
it { should_not be_iceday }
|
447
|
+
it { should be_lightningday }
|
448
|
+
it { should_not be_lightsday }
|
449
|
+
it { should_not be_darksday }
|
450
|
+
end
|
451
|
+
|
452
|
+
context 'when C.E. 1000-01-07' do
|
453
|
+
subject { Vanadiel::Time.new(1000, 1, 7) }
|
454
|
+
it { should_not be_firesday }
|
455
|
+
it { should_not be_earthsday }
|
456
|
+
it { should_not be_watersday }
|
457
|
+
it { should_not be_windsday }
|
458
|
+
it { should_not be_iceday }
|
459
|
+
it { should_not be_lightningday }
|
460
|
+
it { should be_lightsday }
|
461
|
+
it { should_not be_darksday }
|
462
|
+
end
|
463
|
+
|
464
|
+
context 'when C.E. 1000-01-08' do
|
465
|
+
subject { Vanadiel::Time.new(1000, 1, 8) }
|
466
|
+
it { should_not be_firesday }
|
467
|
+
it { should_not be_earthsday }
|
468
|
+
it { should_not be_watersday }
|
469
|
+
it { should_not be_windsday }
|
470
|
+
it { should_not be_iceday }
|
471
|
+
it { should_not be_lightningday }
|
472
|
+
it { should_not be_lightsday }
|
473
|
+
it { should be_darksday }
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
describe Vanadiel::Time, '#to_i' do
|
478
|
+
include_context 'Vanadiel::Time with arguments(2047, 10, 21, 15, 37, 30, 123456)'
|
479
|
+
subject { vana_time.to_i }
|
480
|
+
it { should be_kind_of Integer }
|
481
|
+
it 'should return the time as an integer of seconds' do
|
482
|
+
should === 63663896250
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
describe Vanadiel::Time, '#to_f' do
|
487
|
+
include_context 'Vanadiel::Time with arguments(2047, 10, 21, 15, 37, 30, 123456)'
|
488
|
+
subject { vana_time.to_f }
|
489
|
+
it { should be_kind_of Float }
|
490
|
+
it 'should return the time as an Float of seconds' do
|
491
|
+
should === 63663896250.123456
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
describe Vanadiel::Time, '#strftime' do
|
496
|
+
context 'with 0886-03-04 05:06:07' do
|
497
|
+
let(:vana_time) { Vanadiel::Time.new(886, 3, 4, 5, 6, 7, 80900) }
|
498
|
+
|
499
|
+
patterns = {
|
500
|
+
'%Y' => '886', '%-Y' => '886', '%_Y' => '886', '%0Y' => '886',
|
501
|
+
'%6Y' => '000886', '%-6Y' => '886', '%_6Y' => ' 886', '%06Y' => '000886', '%01Y' => '886',
|
502
|
+
|
503
|
+
'%C' => '8', '%-C' => '8', '%_C' => '8', '%0C' => '8',
|
504
|
+
'%6C' => '000008', '%-6C' => '8', '%_6C' => ' 8', '%06C' => '000008', '%01C' => '8',
|
505
|
+
|
506
|
+
'%y' => '86', '%-y' => '86', '%_y' => '86', '%0y' => '86',
|
507
|
+
'%6y' => '000086', '%-6y' => '86', '%_6y' => ' 86', '%06y' => '000086', '%01y' => '86',
|
508
|
+
|
509
|
+
'%m' => '03', '%-m' => '3', '%_m' => ' 3', '%0m' => '03',
|
510
|
+
'%6m' => '000003', '%-6m' => '3', '%_6m' => ' 3', '%06m' => '000003', '%01m' => '3',
|
511
|
+
|
512
|
+
'%d' => '04', '%-d' => '4', '%_d' => ' 4', '%0d' => '04',
|
513
|
+
'%6d' => '000004', '%-6d' => '4', '%_6d' => ' 4', '%06d' => '000004', '%01d' => '4',
|
514
|
+
|
515
|
+
'%e' => ' 4', '%-e' => '4', '%_e' => ' 4', '%0e' => '04',
|
516
|
+
'%6e' => ' 4', '%-6e' => '4', '%_6e' => ' 4', '%06e' => '000004', '%01e' => '4',
|
517
|
+
|
518
|
+
'%j' => '064', '%-j' => '64', '%_j' => ' 64', '%0j' => '064',
|
519
|
+
'%6j' => '000064', '%-6j' => '64', '%_6j' => ' 64', '%06j' => '000064', '%01j' => '64',
|
520
|
+
|
521
|
+
'%H' => '05', '%-H' => '5', '%_H' => ' 5', '%0H' => '05',
|
522
|
+
'%6H' => '000005', '%-6H' => '5', '%_6H' => ' 5', '%06H' => '000005', '%01H' => '5',
|
523
|
+
|
524
|
+
'%k' => ' 5', '%-k' => '5', '%_k' => ' 5', '%0k' => '05',
|
525
|
+
'%6k' => ' 5', '%-6k' => '5', '%_6k' => ' 5', '%06k' => '000005', '%01k' => '5',
|
526
|
+
|
527
|
+
'%M' => '06', '%-M' => '6', '%_M' => ' 6', '%0M' => '06',
|
528
|
+
'%6M' => '000006', '%-6M' => '6', '%_6M' => ' 6', '%06M' => '000006', '%01M' => '6',
|
529
|
+
|
530
|
+
'%S' => '07', '%-S' => '7', '%_S' => ' 7', '%0S' => '07',
|
531
|
+
'%6S' => '000007', '%-6S' => '7', '%_6S' => ' 7', '%06S' => '000007', '%01S' => '7',
|
532
|
+
|
533
|
+
'%L' => '080', '%-L' => '80', '%_L' => ' 80', '%0L' => '080',
|
534
|
+
'%6L' => '080900', '%-6L' => '80900', '%_6L' => ' 80900', '%06L' => '080900', '%01L' => '0',
|
535
|
+
|
536
|
+
'%N' => '080900', '%-N' => '80900', '%_N' => ' 80900', '%0N' => '080900',
|
537
|
+
'%6N' => '080900', '%-6N' => '80900', '%_6N' => ' 80900', '%06N' => '080900', '%01N' => '0',
|
538
|
+
'%1N' => '0', '%2N' => '08', '%3N' => '080', '%4N' => '0809', '%5N' => '08090',
|
539
|
+
'%7N' => '0809000', '%8N' => '08090000', '%9N' => '080900000', '%12N' => '080900000000',
|
540
|
+
|
541
|
+
'%A' => 'Darksday', '%-A' => 'Darksday', '%_A' => 'Darksday', '%0A' => 'Darksday',
|
542
|
+
'%10A' => ' Darksday', '%-10A' => 'Darksday', '%_10A' => ' Darksday', '%010A' => '00Darksday', '%01A' => 'Darksday',
|
543
|
+
'%^A' => 'DARKSDAY', '%-^A' => 'DARKSDAY', '%_^A' => 'DARKSDAY',
|
544
|
+
'%^10A' => ' DARKSDAY', '%_^10A' => ' DARKSDAY', '%0^10A' => '00DARKSDAY',
|
545
|
+
'%#A' => 'DARKSDAY', '%-#A' => 'DARKSDAY', '%_#A' => 'DARKSDAY',
|
546
|
+
'%#10A' => ' DARKSDAY', '%_#10A' => ' DARKSDAY', '%0#10A' => '00DARKSDAY',
|
547
|
+
|
548
|
+
'%w' => '7', '%-w' => '7', '%_w' => '7', '%0w' => '7',
|
549
|
+
'%6w' => '000007', '%-6w' => '7', '%_6w' => ' 7', '%06w' => '000007', '%01w' => '7',
|
550
|
+
|
551
|
+
'%s' => '27532501567080900', '%-s' => '27532501567080900', '%_s' => '27532501567080900', '%0s' => '27532501567080900',
|
552
|
+
'%20s' => '00027532501567080900', '%-20s' => '27532501567080900', '%_20s' => ' 27532501567080900', '%020s' => '00027532501567080900', '%01s' => '27532501567080900',
|
553
|
+
|
554
|
+
'%n' => "\n", '%-n' => "\n", '%_n' => "\n", '%0n' => "\n",
|
555
|
+
'%3n' => " \n", '%-3n' => "\n", '%_3n' => " \n", '%03n' => "00\n", '%01n' => "\n",
|
556
|
+
|
557
|
+
'%t' => "\t", '%-t' => "\t", '%_t' => "\t", '%0t' => "\t",
|
558
|
+
'%3t' => " \t", '%-3t' => "\t", '%_3t' => " \t", '%03t' => "00\t", '%01t' => "\t",
|
559
|
+
|
560
|
+
'%%' => '%', '%-%' => '%', '%_%' => '%', '%0%' => '%',
|
561
|
+
'%3%' => ' %', '%-3%' => '%', '%_3%' => ' %', '%03%' => '00%', '%01%' => '%',
|
562
|
+
|
563
|
+
'%F' => '886-03-04', '%-F' => '886-03-04', '%_F' => '886-03-04', '%0F' => '886-03-04',
|
564
|
+
'%12F' => '886-03-04', '%-12F' => '886-03-04', '%_12F' => '886-03-04', '%012F' => '886-03-04', '%01F' => '886-03-04',
|
565
|
+
'%^F' => '886-03-04', '%#F' => '886-03-04', '%_^F' => '886-03-04', '%0#F' => '886-03-04',
|
566
|
+
|
567
|
+
'%T' => '05:06:07', '%-T' => '05:06:07', '%_T' => '05:06:07', '%0T' => '05:06:07',
|
568
|
+
'%12T' => '05:06:07', '%-12T' => '05:06:07', '%_12T' => '05:06:07', '%012T' => '05:06:07', '%01T' => '05:06:07',
|
569
|
+
'%^T' => '05:06:07', '%#T' => '05:06:07', '%_^T' => '05:06:07', '%0#T' => '05:06:07',
|
570
|
+
|
571
|
+
'%X' => '05:06:07', '%-X' => '05:06:07', '%_X' => '05:06:07', '%0X' => '05:06:07',
|
572
|
+
'%12X' => '05:06:07', '%-12X' => '05:06:07', '%_12X' => '05:06:07', '%012X' => '05:06:07', '%01X' => '05:06:07',
|
573
|
+
'%^X' => '05:06:07', '%#X' => '05:06:07', '%_^X' => '05:06:07', '%0#X' => '05:06:07',
|
574
|
+
|
575
|
+
'%R' => '05:06', '%-R' => '05:06', '%_R' => '05:06', '%0R' => '05:06',
|
576
|
+
'%12R' => '05:06', '%-12R' => '05:06', '%_12R' => '05:06', '%012R' => '05:06', '%01R' => '05:06',
|
577
|
+
'%^R' => '05:06', '%#R' => '05:06', '%_^R' => '05:06', '%0#R' => '05:06',
|
578
|
+
|
579
|
+
"Vana'diel %F %T" => "Vana'diel 886-03-04 05:06:07",
|
580
|
+
"Vana'diel %Y/%m/%d %H:%M:%S" => "Vana'diel 886/03/04 05:06:07",
|
581
|
+
}
|
582
|
+
|
583
|
+
patterns.each {|conversion, expect|
|
584
|
+
describe conversion do
|
585
|
+
subject { vana_time.strftime(conversion) }
|
586
|
+
it { should == expect }
|
587
|
+
end
|
588
|
+
}
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
describe Vanadiel::Time, '#==' do
|
593
|
+
context 'with same value different object' do
|
594
|
+
let(:other) { described_class.new(2047, 10, 21) }
|
595
|
+
subject { described_class.new(2047, 10, 21) }
|
596
|
+
it 'should be true' do
|
597
|
+
should == other
|
598
|
+
end
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
describe Vanadiel::Time, '#eql?' do
|
603
|
+
context 'with same value different object' do
|
604
|
+
let(:other) { described_class.new(2047, 10, 21) }
|
605
|
+
subject { described_class.new(2047, 10, 21) }
|
606
|
+
it 'should be true' do
|
607
|
+
should eql other
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
describe Vanadiel::Time, '#+' do
|
613
|
+
context 'with 10.123456' do
|
614
|
+
subject { described_class.new(2047, 10, 21) + 10.123456 }
|
615
|
+
it 'should add 10.123456sec and returns that value as a new time' do
|
616
|
+
should == described_class.new(2047, 10, 21, 0, 0, 10, 123456)
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
context 'with -10.123456' do
|
621
|
+
subject { described_class.new(2047, 10, 21) + -10.123456 }
|
622
|
+
it 'should subtract 10.123456sec and returns that value as a new time' do
|
623
|
+
should == described_class.new(2047, 10, 20, 23, 59, 49, 876544)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
describe Vanadiel::Time, '#-' do
|
629
|
+
context 'with 10.123456' do
|
630
|
+
subject { described_class.new(2047, 10, 21) - 10.123456 }
|
631
|
+
it 'should subtract 10.123456sec and returns that value as a new time' do
|
632
|
+
should == described_class.new(2047, 10, 20, 23, 59, 49, 876544)
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
context 'with -10.123456' do
|
637
|
+
subject { described_class.new(2047, 10, 21) - -10.123456 }
|
638
|
+
it 'should add 10.123456sec and returns that value as a new time' do
|
639
|
+
should == described_class.new(2047, 10, 21, 0, 0, 10, 123456)
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
context "with Vana'diel time" do
|
644
|
+
before do
|
645
|
+
@sec = 10.123456
|
646
|
+
@vt = described_class.new(2047, 10, 21)
|
647
|
+
end
|
648
|
+
subject { @vt - (@vt - @sec) }
|
649
|
+
it 'should return difference sec' do
|
650
|
+
should == @sec
|
651
|
+
end
|
652
|
+
it 'should return Float' do
|
653
|
+
(@vt - (@vt - 10)).should be_kind_of Float
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
describe Vanadiel::Time, '#<=>' do
|
659
|
+
context 'with later(greater) time' do
|
660
|
+
subject { described_class.new(2047, 10, 21) <=> described_class.new(2047, 10, 22) }
|
661
|
+
it { should == -1 }
|
662
|
+
end
|
663
|
+
|
664
|
+
context 'with earlier(less) time' do
|
665
|
+
subject { described_class.new(2047, 10, 21) <=> described_class.new(2047, 10, 20) }
|
666
|
+
it { should == 1 }
|
667
|
+
end
|
668
|
+
|
669
|
+
context 'with same time' do
|
670
|
+
subject { described_class.new(2047, 10, 21) <=> described_class.new(2047, 10, 21) }
|
671
|
+
it { should == 0 }
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
describe Vanadiel::Time, '#marshal_dump, #marshal_load' do
|
676
|
+
subject { described_class.new(2047, 10, 21) }
|
677
|
+
it 'should dump and load correctly' do
|
678
|
+
dumped = Marshal.dump(subject)
|
679
|
+
loaded = Marshal.load(dumped)
|
680
|
+
subject.should == loaded
|
681
|
+
end
|
682
|
+
end
|