diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-05 22:53:39 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-05 22:53:39 +0900 |
| commit | 2ceb71f97021d6d42b802e7edf522dd16357a932 (patch) | |
| tree | a3b62a093a7412beb2648103ec4bb306b7b8cdae | |
| parent | f0b0a2dd625a0a66d93542a5b6b55ba98045c70d (diff) | |
| parent | 7bab3d0bb24510103299c3fbebd6e3ce4622939a (diff) | |
| download | mruby-2ceb71f97021d6d42b802e7edf522dd16357a932.tar.gz mruby-2ceb71f97021d6d42b802e7edf522dd16357a932.zip | |
Merge pull request #2201 from take-cheeze/day_of_week
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 |
