diff options
| author | take_cheeze <[email protected]> | 2014-05-05 22:41:16 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2014-05-05 22:41:16 +0900 |
| commit | 7bab3d0bb24510103299c3fbebd6e3ce4622939a (patch) | |
| tree | 46d843d550798bdcb2e810d5845c138aef596c5a | |
| parent | 02cabf8fa7aacb1063d73105dbcf59bccee87470 (diff) | |
| download | mruby-7bab3d0bb24510103299c3fbebd6e3ce4622939a.tar.gz mruby-7bab3d0bb24510103299c3fbebd6e3ce4622939a.zip | |
Implement day of week methods.
| -rw-r--r-- | mrbgems/mruby-time/mrblib/time.rb | 9 | ||||
| -rw-r--r-- | mrbgems/mruby-time/test/time.rb | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/mrbgems/mruby-time/mrblib/time.rb b/mrbgems/mruby-time/mrblib/time.rb new file mode 100644 index 000000000..df0d8ca82 --- /dev/null +++ b/mrbgems/mruby-time/mrblib/time.rb @@ -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 diff --git a/mrbgems/mruby-time/test/time.rb b/mrbgems/mruby-time/test/time.rb index f92459d5e..40884e642 100644 --- a/mrbgems/mruby-time/test/time.rb +++ b/mrbgems/mruby-time/test/time.rb @@ -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 |
