marsdate 1.1.3 → 2.0.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +650 -0
- data/bin/marsdate +167 -15
- data/lib/marsdate/calendar.rb +128 -0
- data/lib/marsdate/timescale.rb +314 -0
- data/lib/marsdate/version.rb +3 -0
- data/lib/marsdate.rb +289 -241
- data/marsdate.gemspec +31 -0
- data/test/calendar_test.rb +142 -0
- data/test/cli_test.rb +57 -0
- data/test/test.rb +305 -313
- data/test/timescale_test.rb +124 -0
- metadata +51 -19
- data/bin/marsdate-version +0 -5
- data/bin/mcal.rb +0 -50
- data/bin/meh.html +0 -2941
- data/bin/mkcal.rb +0 -51
- data/bin/mtcon.rb +0 -29
- data/bin/mtoday.rb +0 -5
- data/test/spec/marsdate_spec.rb +0 -382
data/bin/mkcal.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require 'marsdate'
|
|
2
|
-
|
|
3
|
-
def month(year, n)
|
|
4
|
-
dow = MarsDateTime.new(year, n, 1).dow
|
|
5
|
-
ndays = 28
|
|
6
|
-
list = [""]*dow + (1..ndays).to_a
|
|
7
|
-
l2 = []
|
|
8
|
-
loop do
|
|
9
|
-
l2 << list.slice!(0..6)
|
|
10
|
-
break if list.empty?
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
puts "<table border=1>"
|
|
14
|
-
puts "<tr><td colspan=7"
|
|
15
|
-
puts "<b><center><font size=+1>#{MarsDateTime::Months[n]}</font><center></b>"
|
|
16
|
-
puts "</td></tr>"
|
|
17
|
-
puts "<tr>"
|
|
18
|
-
puts "<td><b>Sun</b></td>"
|
|
19
|
-
puts "<td><b>Mon</b></td>"
|
|
20
|
-
puts "<td><b>Tue</b></td>"
|
|
21
|
-
puts "<td><b>Wed</b></td>"
|
|
22
|
-
puts "<td><b>Thu</b></td>"
|
|
23
|
-
puts "<td><b>Fri</b></td>"
|
|
24
|
-
puts "<td><b>Sat</b></td>"
|
|
25
|
-
puts "</tr>"
|
|
26
|
-
l2.each do |week|
|
|
27
|
-
puts "<tr>"
|
|
28
|
-
week.each do |day|
|
|
29
|
-
puts " <td>"
|
|
30
|
-
puts day
|
|
31
|
-
puts " </td>"
|
|
32
|
-
end
|
|
33
|
-
puts "</tr>"
|
|
34
|
-
end
|
|
35
|
-
puts "</table>"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def row(yr,i)
|
|
39
|
-
puts "<tr>"
|
|
40
|
-
puts "<td>"; month yr, i+1; puts "</td>"
|
|
41
|
-
puts "<td>"; month yr, i+2; puts "</td>"
|
|
42
|
-
puts "<td>"; month yr, i+3; puts "</td>"
|
|
43
|
-
puts "<td>"; month yr, i+4; puts "</td>"
|
|
44
|
-
puts "</tr>"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
year = ARGV.first.to_i
|
|
48
|
-
|
|
49
|
-
puts "<table>"
|
|
50
|
-
6.times {|i| row(year,i*4) }
|
|
51
|
-
|
data/bin/mtcon.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'marsdate'
|
|
2
|
-
|
|
3
|
-
case ARGV.size
|
|
4
|
-
when 0
|
|
5
|
-
abort "Parameters: (me|em) yyyy/mm/dd"
|
|
6
|
-
when 1 # Clunky - assume am2k
|
|
7
|
-
date = DateTime.new(2000,1,5,19,0,0)
|
|
8
|
-
mdate = MarsDateTime.new(date)
|
|
9
|
-
puts mdate.inspect
|
|
10
|
-
puts mdate.to_s
|
|
11
|
-
when 2,3
|
|
12
|
-
action, date, time = ARGV
|
|
13
|
-
time ||= "00:00:00"
|
|
14
|
-
|
|
15
|
-
yyyy,mm,dd = date.split("/").map {|x| x.to_i }
|
|
16
|
-
hh,mi,ss = time.split(":").map {|x| x.to_i }
|
|
17
|
-
|
|
18
|
-
case action
|
|
19
|
-
when "em"
|
|
20
|
-
date = DateTime.new(yyyy,mm,dd,hh,mi,ss)
|
|
21
|
-
mdate = MarsDateTime.new(date)
|
|
22
|
-
puts mdate.inspect
|
|
23
|
-
puts mdate.to_s
|
|
24
|
-
when "me"
|
|
25
|
-
mdate = MarsDateTime.new(yyyy,mm,dd)
|
|
26
|
-
date = mdate.earth_date
|
|
27
|
-
puts date.strftime("%x %X")
|
|
28
|
-
end
|
|
29
|
-
end
|
data/bin/mtoday.rb
DELETED
data/test/spec/marsdate_spec.rb
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
$: << "lib"
|
|
2
|
-
require 'marsdate'
|
|
3
|
-
|
|
4
|
-
require 'rubygems'
|
|
5
|
-
require 'minitest'
|
|
6
|
-
require 'minitest/spec'
|
|
7
|
-
require 'minitest/autorun'
|
|
8
|
-
|
|
9
|
-
require 'pp'
|
|
10
|
-
|
|
11
|
-
def my_assert(expr)
|
|
12
|
-
if !expr && block_given?
|
|
13
|
-
puts "\n--- DEBUG: "
|
|
14
|
-
yield
|
|
15
|
-
end
|
|
16
|
-
assert(expr)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def my_assert_equal(e1, e2)
|
|
20
|
-
if e1 != e2 && block_given?
|
|
21
|
-
puts "\n--- DEBUG: "
|
|
22
|
-
yield
|
|
23
|
-
end
|
|
24
|
-
assert_equal(e1, e2)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
## experimenting...
|
|
28
|
-
|
|
29
|
-
describe "Mars date 1/1/1" do
|
|
30
|
-
md = MarsDateTime.new(1,1,1)
|
|
31
|
-
it "should compute backwards to same result" do
|
|
32
|
-
assert_equal([1,1,1,0,0,0],md.ymshms)
|
|
33
|
-
end
|
|
34
|
-
it "should be a Sunday" do
|
|
35
|
-
assert_equal(0,md.dow)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe "Mars date 2/3/4" do
|
|
40
|
-
md = MarsDateTime.new(2,3,4)
|
|
41
|
-
it "should compute backwards to same result" do
|
|
42
|
-
assert_equal([2,3,4,0,0,0],md.ymshms)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe "Mars date 5/4/24" do
|
|
47
|
-
md = MarsDateTime.new(5,4,24)
|
|
48
|
-
it "should compute backwards to same result" do
|
|
49
|
-
assert_equal([5,4,24,0,0,0],md.ymshms)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe "Mars date 1054/20/20" do
|
|
54
|
-
md = MarsDateTime.new(1054,20,20)
|
|
55
|
-
it "should compute backwards to same result" do
|
|
56
|
-
assert_equal([1054,20,20,0,0,0],md.ymshms)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe "Earth date 1/1/22" do
|
|
61
|
-
ed = DateTime.new(1,1,22)
|
|
62
|
-
md = MarsDateTime.new(ed)
|
|
63
|
-
it "should be approximately M-date 1/1/1" do
|
|
64
|
-
assert_equal([1,1,1],md.ymshms[0..2])
|
|
65
|
-
end
|
|
66
|
-
it "should yield a Martian Sunday" do
|
|
67
|
-
assert_equal(md.day_of_week,"Sunday")
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
describe "Earth date May 23, 1961" do
|
|
72
|
-
e = DateTime.new(1961,5,23)
|
|
73
|
-
m = MarsDateTime.new(e)
|
|
74
|
-
it "should yield a Martian Thursday" do
|
|
75
|
-
assert_equal(m.day_of_week,"Thursday")
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe "Earth date May 24, 1961" do
|
|
80
|
-
e = DateTime.new(1961,5,24)
|
|
81
|
-
m = MarsDateTime.new(e)
|
|
82
|
-
it "should yield a Martian Friday" do
|
|
83
|
-
assert_equal(m.day_of_week,"Friday")
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "A Martian date/time (y,m,s,h,m,s)" do
|
|
88
|
-
m = MarsDateTime.new(1043,2,15,12,34,45)
|
|
89
|
-
it "should set all its accessors properly" do
|
|
90
|
-
assert_equal(1043,m.myear)
|
|
91
|
-
assert_equal(2,m.month)
|
|
92
|
-
assert_equal(15,m.sol)
|
|
93
|
-
assert_equal(12,m.hr)
|
|
94
|
-
assert_equal(34,m.min)
|
|
95
|
-
assert_equal(45,m.sec)
|
|
96
|
-
assert_equal(4,m.dow)
|
|
97
|
-
assert_equal("Thursday",m.day_of_week)
|
|
98
|
-
assert_equal(43,m.year_sol)
|
|
99
|
-
assert_equal(696715,m.epoch_sol)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
describe "The 2007 Martian equinox" do
|
|
104
|
-
e = DateTime.new(2007,12,9,17,20,0).new_offset(-5)
|
|
105
|
-
m = MarsDateTime.new(e)
|
|
106
|
-
m11 = MarsDateTime.new(1068,1,1)
|
|
107
|
-
it "should fall on or near 1/1 (MCE)" do
|
|
108
|
-
diff = (m11-m).abs
|
|
109
|
-
flag = diff < 1.0
|
|
110
|
-
assert(flag, "Difference: #{diff}")
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
describe "Constructing without parameters" do
|
|
115
|
-
m = MarsDateTime.new
|
|
116
|
-
e = DateTime.now
|
|
117
|
-
m2e = m.earth_date
|
|
118
|
-
it "should default to today" do
|
|
119
|
-
diff = (e-m2e).abs # m - e doesn't work!
|
|
120
|
-
assert(diff < 1.0)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
describe "Constructing with a DateTime" do
|
|
125
|
-
it "should convert from Gregorian to MCE" do
|
|
126
|
-
e = DateTime.new(1902,8,12,7,0,0)
|
|
127
|
-
m = MarsDateTime.new(e)
|
|
128
|
-
diff = (m.earth_date - e).abs # days as a float
|
|
129
|
-
x = assert(diff < 1.0)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe "A Martian date/time (933,1,2)" do
|
|
134
|
-
m = MarsDateTime.new(933,1,2)
|
|
135
|
-
it "should set the three obvious accessors properly" do
|
|
136
|
-
assert_equal(933,m.myear)
|
|
137
|
-
assert_equal(1,m.month)
|
|
138
|
-
assert_equal(2,m.sol)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
describe "A Martian date/time (933,1,1)" do
|
|
143
|
-
m = MarsDateTime.new(933,1,1)
|
|
144
|
-
it "should set the three obvious accessors properly" do
|
|
145
|
-
assert_equal(933,m.myear)
|
|
146
|
-
assert_equal(1,m.month)
|
|
147
|
-
assert_equal(1,m.sol)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
describe "The Martian date 24/25" do
|
|
152
|
-
describe "in a leap year" do
|
|
153
|
-
year = 1067
|
|
154
|
-
it "should exist" do
|
|
155
|
-
assert( MarsDateTime.leap?(year) )
|
|
156
|
-
MarsDateTime.new(year,24,25) # may raise exception - no #wont_raise
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
describe "in a non-leap year" do
|
|
160
|
-
year = 1066
|
|
161
|
-
it "should not exist" do
|
|
162
|
-
assert( ! MarsDateTime.leap?(year) )
|
|
163
|
-
lambda { MarsDateTime.new(year,24,25) }.must_raise(RuntimeError)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
describe "The earth_date convertor" do
|
|
169
|
-
m = MarsDateTime.new(1,1,1)
|
|
170
|
-
it "should convert to a Gregorian date" do
|
|
171
|
-
e = m.earth_date
|
|
172
|
-
assert_equal(1,e.year)
|
|
173
|
-
assert_equal(1,e.month)
|
|
174
|
-
assert((e.day-22).abs <= 1, "e - 22 = #{e.day - 22}")
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
describe "An Earthly date" do
|
|
179
|
-
e1 = DateTime.new(1961,5,31)
|
|
180
|
-
it "should (approximately) make the conversion roundtrip" do
|
|
181
|
-
m1 = MarsDateTime.new(e1)
|
|
182
|
-
e2 = m1.earth_date
|
|
183
|
-
diff = e2 - e1
|
|
184
|
-
assert(diff.abs <= 0.01, "Difference = #{diff}")
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
describe "A Martian date" do
|
|
189
|
-
m1 = MarsDateTime.new(1067,1,1)
|
|
190
|
-
it "should (approximately) make the conversion roundtrip" do
|
|
191
|
-
e1 = m1.earth_date
|
|
192
|
-
m2 = MarsDateTime.new(e1)
|
|
193
|
-
diff = m2 - m1
|
|
194
|
-
assert(diff.abs < 0.01)
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
describe "An arbitrary Martian date" do
|
|
199
|
-
m1 = MarsDateTime.new(1069,15,24)
|
|
200
|
-
m2 = MarsDateTime.new(933,6,4)
|
|
201
|
-
m3 = MarsDateTime.new(1055,14,1)
|
|
202
|
-
it "should format well with strftime" do
|
|
203
|
-
assert_equal("Mon",m1.strftime("%a"))
|
|
204
|
-
assert_equal("Monday",m1.strftime("%A"))
|
|
205
|
-
assert_equal("Aug",m1.strftime("%b"))
|
|
206
|
-
assert_equal("M-August",m1.strftime("%B"))
|
|
207
|
-
assert_equal("24",m1.strftime("%d"))
|
|
208
|
-
assert_equal("24",m1.strftime("%e"))
|
|
209
|
-
assert_equal("1069-15-24",m1.strftime("%F"))
|
|
210
|
-
assert_equal("416",m1.strftime("%j"))
|
|
211
|
-
assert_equal("15",m1.strftime("%m"))
|
|
212
|
-
assert_equal("0",m1.strftime("%s"))
|
|
213
|
-
assert_equal("2",m1.strftime("%u"))
|
|
214
|
-
assert_equal("60",m1.strftime("%U"))
|
|
215
|
-
assert_equal("1",m1.strftime("%w"))
|
|
216
|
-
assert_equal("1069/15/24",m1.strftime("%x"))
|
|
217
|
-
assert_equal("1069",m1.strftime("%Y"))
|
|
218
|
-
assert_equal("\n",m1.strftime("%n"))
|
|
219
|
-
assert_equal("\t",m1.strftime("%t"))
|
|
220
|
-
assert_equal("%",m1.strftime("%%"))
|
|
221
|
-
|
|
222
|
-
assert_equal("Wed",m2.strftime("%a"))
|
|
223
|
-
assert_equal("Wednesday",m2.strftime("%A"))
|
|
224
|
-
assert_equal("Leo",m2.strftime("%b"))
|
|
225
|
-
assert_equal("Leo",m2.strftime("%B"))
|
|
226
|
-
assert_equal("04",m2.strftime("%d"))
|
|
227
|
-
assert_equal(" 4",m2.strftime("%e"))
|
|
228
|
-
assert_equal("933-06-04",m2.strftime("%F"))
|
|
229
|
-
assert_equal("144",m2.strftime("%j"))
|
|
230
|
-
assert_equal("06",m2.strftime("%m"))
|
|
231
|
-
assert_equal("0",m2.strftime("%s"))
|
|
232
|
-
assert_equal("4",m2.strftime("%u"))
|
|
233
|
-
assert_equal("21",m2.strftime("%U"))
|
|
234
|
-
assert_equal("3",m2.strftime("%w"))
|
|
235
|
-
assert_equal("933/06/04",m2.strftime("%x"))
|
|
236
|
-
assert_equal("933",m2.strftime("%Y"))
|
|
237
|
-
|
|
238
|
-
assert_equal("Sag",m3.strftime("%b"))
|
|
239
|
-
assert_equal("Sagittarius",m3.strftime("%B"))
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
describe "An Earthly date with h:m:s" do
|
|
244
|
-
e1 = DateTime.new(1976,7,4,16,30,0) # July 4, 1976 16:30
|
|
245
|
-
m1 = MarsDateTime.new(e1)
|
|
246
|
-
it "should make the conversion roundtrip" do
|
|
247
|
-
30.times do
|
|
248
|
-
m1 = MarsDateTime.new(e1)
|
|
249
|
-
e2 = m1.earth_date
|
|
250
|
-
diff = e2 - e1
|
|
251
|
-
assert(diff.abs <= 0.01) { STDERR.puts " diff = #{diff}" }
|
|
252
|
-
e1 += 1
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
describe "Martian dates" do
|
|
258
|
-
m1 = MarsDateTime.new(1068,14,22)
|
|
259
|
-
m2 = MarsDateTime.new(1068,14,21)
|
|
260
|
-
e1 = DateTime.new(2002,4,19)
|
|
261
|
-
e2 = DateTime.new(2012,9,29)
|
|
262
|
-
it "should compare with each other" do
|
|
263
|
-
assert(m1 > m2)
|
|
264
|
-
assert(m2 < m1)
|
|
265
|
-
end
|
|
266
|
-
it "should compare with Earth dates" do
|
|
267
|
-
assert(m1 > e1)
|
|
268
|
-
assert(m2 < e2)
|
|
269
|
-
end
|
|
270
|
-
it "should honor equality (within roundoff)" do
|
|
271
|
-
assert(m1 == m1)
|
|
272
|
-
assert(m1 != m2)
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
describe "The 'now' and 'today' class methods" do
|
|
277
|
-
t1 = MarsDateTime.now
|
|
278
|
-
t0 = MarsDateTime.today
|
|
279
|
-
it "should be less than a day apart" do
|
|
280
|
-
diff = t1 - t0
|
|
281
|
-
assert(diff < 1.0)
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
describe "In M-year 1043, each month" do
|
|
286
|
-
md = (1..24).to_a.map {|mm| MarsDateTime.new(1043,mm,1) }
|
|
287
|
-
it "should start on a Thursday" do
|
|
288
|
-
md.each {|m| assert(m.day_of_week == "Thursday") }
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
describe "Converting 1961/5/31 to Martian" do
|
|
293
|
-
e = DateTime.new(1961,5,31)
|
|
294
|
-
m = MarsDateTime.new(e)
|
|
295
|
-
it "should yield Friday M-April 9, 1043 MCE" do
|
|
296
|
-
assert(m.year == 1043, "bad year: #{m.year}")
|
|
297
|
-
assert(m.month == 7, "bad month: #{m.month}")
|
|
298
|
-
assert(m.sol == 9, "bad sol: #{m.sol}")
|
|
299
|
-
end
|
|
300
|
-
it "should give a Martian Saturday" do
|
|
301
|
-
assert(m.day_of_week == "Friday", "got: #{m.day_of_week}")
|
|
302
|
-
end
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
describe "The 1609 Martian equinox" do
|
|
306
|
-
e = DateTime.new(1609,3,12).new_offset(-5)
|
|
307
|
-
m = MarsDateTime.new(e)
|
|
308
|
-
m11 = MarsDateTime.new(856,1,1)
|
|
309
|
-
it "should fall on or near 1/1 (MCE)" do
|
|
310
|
-
diff = (m11-m).abs
|
|
311
|
-
assert(diff < 1.0, "Difference = #{diff}")
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
describe "The 1902 Martian equinox" do
|
|
316
|
-
e = DateTime.new(1902,8,12,7,0,0).new_offset(-5)
|
|
317
|
-
m = MarsDateTime.new(e)
|
|
318
|
-
m11 = MarsDateTime.new(1012,1,1)
|
|
319
|
-
it "should fall on or near 1/1 (MCE)" do
|
|
320
|
-
diff = (m11-m).abs
|
|
321
|
-
assert(diff < 1.0, "Difference: #{diff}")
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
describe "A Martian date" do
|
|
326
|
-
puts "***** Entering problem test..."
|
|
327
|
-
m = MarsDateTime.new(1068,1,1)
|
|
328
|
-
p m
|
|
329
|
-
describe "plus 7 days" do
|
|
330
|
-
m2 = m + 7
|
|
331
|
-
p m2
|
|
332
|
-
it "should be the same day of the week" do
|
|
333
|
-
assert_equal(m.day_of_week, m2.day_of_week)
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
describe "plus 14 days" do
|
|
337
|
-
m3 = m + 14
|
|
338
|
-
p m3
|
|
339
|
-
it "should be the same day of the week" do
|
|
340
|
-
assert_equal(m.day_of_week, m3.day_of_week)
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
describe "plus 21 days" do
|
|
344
|
-
m4 = m + 21
|
|
345
|
-
p m4
|
|
346
|
-
it "should be the same day of the week" do
|
|
347
|
-
assert_equal(m.day_of_week, m4.day_of_week)
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
puts "***** Exiting problem test"
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
describe "Martian April 1, 1043" do
|
|
354
|
-
m = MarsDateTime.new(1043,7,1)
|
|
355
|
-
it "should be a Thursday" do
|
|
356
|
-
assert_equal(m.day_of_week,"Thursday")
|
|
357
|
-
end
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
describe "A Martian date" do
|
|
361
|
-
md = MarsDateTime.new(1062,20,20)
|
|
362
|
-
m2 = MarsDateTime.new(1062,20,17)
|
|
363
|
-
it "should allow subtraction of another date" do
|
|
364
|
-
m = md - m2
|
|
365
|
-
assert( (m - 3.0) < 0.01) # sols
|
|
366
|
-
end
|
|
367
|
-
it "should allow subtraction of an Earth date" do
|
|
368
|
-
e = DateTime.new(1998, 3, 12, 16, 45, 0)
|
|
369
|
-
m = md - e
|
|
370
|
-
assert( (m - 3.0) < 0.01) # sols
|
|
371
|
-
end
|
|
372
|
-
it "should allow subtraction of a Fixnum" do
|
|
373
|
-
m = md - 3 # sols
|
|
374
|
-
assert( (m - m2) < 0.01)
|
|
375
|
-
end
|
|
376
|
-
it "should allow subtraction of a Float" do
|
|
377
|
-
m = md - 3.0 # sols
|
|
378
|
-
assert( (m - m2) < 0.01)
|
|
379
|
-
end
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
|