Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #on_weekday? method to Date, Time, and DateTime. #23687

Merged
merged 1 commit into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
* Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.

`#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
or Sunday.

*Vipul A M*

* Add `Array#second_to_last` and `Array#third_to_last` methods.

*Brian Christian*

* Fix regression in `Hash#dig` for HashWithIndifferentAccess.

*Jon Moss*

## Rails 5.0.0.beta2 (February 01, 2016) ##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def on_weekend?
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)
Expand Down
10 changes: 10 additions & 0 deletions activesupport/test/core_ext/date_and_time_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ def test_on_weekend_on_monday
assert_not date_time_init(2015,1,5,15,15,10).on_weekend?
end

def test_on_weekday_on_sunday
assert_not date_time_init(2015,1,4,0,0,0).on_weekday?
assert_not date_time_init(2015,1,4,15,15,10).on_weekday?
end

def test_on_weekday_on_monday
assert date_time_init(2015,1,5,0,0,0).on_weekday?
assert date_time_init(2015,1,5,15,15,10).on_weekday?
end

def with_bw_default(bw = :monday)
old_bw = Date.beginning_of_week
Date.beginning_of_week = bw
Expand Down
2 changes: 1 addition & 1 deletion guides/source/5_0_release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ Please refer to the [Changelog][active-support] for detailed changes.
* Changed the default test order from `:sorted` to `:random`.
([commit](https://github.com/rails/rails/commit/5f777e4b5ee2e3e8e6fd0e2a208ec2a4d25a960d))

* Added `#on_weekend?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
* Added `#on_weekend?`, `#on_weekday?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
`Time`, and `DateTime`.
([Pull Request](https://github.com/rails/rails/pull/18335))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add this PR link (23687) in the release notes too. The PR 18335 doesn't add on_weekday.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

On Monday 15 February 2016, Vijay Dev notifications@github.com wrote:

In guides/source/5_0_release_notes.md
#23687 (comment):

@@ -705,7 +705,7 @@ Please refer to the [Changelog][active-support] for detailed changes.

  • Changed the default test order from :sorted to :random.
    (commit)

-* Added #on_weekend?, #next_weekday, #prev_weekday methods to Date,
+* Added #on_weekend?, #on_weekday?, #next_weekday, #prev_weekday methods to Date,
Time, and DateTime.
(Pull Request)

We can add this PR link (23687) in the release notes too. The PR 18335
doesn't add on_weekday.


Reply to this email directly or view it on GitHub
https://github.com/rails/rails/pull/23687/files#r52901426.

Vipul A.M.
+91-8149-204995


Expand Down