mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Implement day of week methods.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class Time
|
||||
def sunday?; wday == 0 end
|
||||
def monday?; wday == 1 end
|
||||
def tuesday?; wday == 2 end
|
||||
def wednesday?; wday == 3 end
|
||||
def thursday?; wday == 4 end
|
||||
def friday?; wday == 5 end
|
||||
def saturday?; wday == 6 end
|
||||
end
|
||||
@@ -197,5 +197,16 @@ if Object.const_defined?(:Time)
|
||||
assert('Time#inspect') do
|
||||
Time.at(1300000000.0).utc.inspect == "Sun Mar 13 07:06:40 UTC 2011"
|
||||
end
|
||||
|
||||
assert('day of week methods') do
|
||||
t = Time.gm(2012, 12, 24)
|
||||
assert_false t.sunday?
|
||||
assert_true t.monday?
|
||||
assert_false t.tuesday?
|
||||
assert_false t.wednesday?
|
||||
assert_false t.thursday?
|
||||
assert_false t.friday?
|
||||
assert_false t.saturday?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user