aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2016-02-15 18:16:51 +0530
committerVipul A M <vipulnsward@gmail.com>2016-02-15 18:16:51 +0530
commit02a9e03c352e7c10e379368f6b41b0e2eaede07c (patch)
tree2d0f9f4a4eb8d6718c80958d5a6fd85d7b71e222 /activesupport/lib/active_support
parentf800e00f9a7150f81dc2d27c26e6d1164df776f3 (diff)
downloadrails-02a9e03c352e7c10e379368f6b41b0e2eaede07c.tar.gz
rails-02a9e03c352e7c10e379368f6b41b0e2eaede07c.tar.bz2
rails-02a9e03c352e7c10e379368f6b41b0e2eaede07c.zip
Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/date_and_time/calculations.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb
index e079af594d..2de0d19a7e 100644
--- a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb
@@ -51,6 +51,11 @@ module DateAndTime
WEEKEND_DAYS.include?(wday)
end
+ # Returns true if the date/time does not fall on a Saturday or Sunday.
+ def on_weekday?
+ !WEEKEND_DAYS.include?(wday)
+ end
+
# Returns a new date/time the specified number of days ago.
def days_ago(days)
advance(:days => -days)