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 support for localized date references #12822

Merged
merged 2 commits into from Dec 3, 2013

Conversation

@cbartlett
Copy link
Contributor

@cbartlett cbartlett commented Nov 9, 2013

Ruby's Date class automatically gives us #yesterday, #today, and #tomorrow. And ActiveSupport has a handy Time.zone.today for getting a localized version. But there was no localized version of #yesterday or #tomorrow.

This patch adds those methods.

Any thoughts on this? I think if we offer #today to mimic the behavior of Date, perhaps we should also offer #tomorrow and #yesterday? I ran into the problem when localizing an app and converting a bunch of Date.today and Date.tomorrow usages.

@senny
Copy link
Member

@senny senny commented Nov 9, 2013

@senny
senny reviewed Dec 3, 2013
View changes
activesupport/test/time_zone_test.rb Outdated
@@ -99,6 +99,28 @@ def test_today
assert_equal Date.new(2000, 1, 2), ActiveSupport::TimeZone['Eastern Time (US & Canada)'].today
end

def test_tomorrow
Time.stubs(:now).returns(Time.utc(2000, 1, 1, 4, 59, 59)) # 1 sec before midnight Jan 1 EST

This comment has been minimized.

This comment has been minimized.

@cbartlett

cbartlett Dec 3, 2013
Author Contributor

TIL. This was just following the convention of the method above. Should I update this test? And leave the rest of them, or change them all?

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Dec 3, 2013
Member

Feel free to change test_today too.

@pixeltrix
Copy link
Member

@pixeltrix pixeltrix commented Dec 3, 2013

@cbartlett can you provide a CHANGELOG entry as well - thanks

@cbartlett
Copy link
Contributor Author

@cbartlett cbartlett commented Dec 3, 2013

@pixeltrix CHANGELOG added.

cbartlett added 2 commits Dec 3, 2013
Ruby's Date class automatically gives us #yesterday, #today,
and #tomorrow. And ActiveSupport has a handy Time.zone.today
for getting a localized version. But there was no localized
version of #yesterday or #tomorrow. Until now.
@cbartlett
Copy link
Contributor Author

@cbartlett cbartlett commented Dec 3, 2013

@senny @carlosantoniodasilva All done. Test update to use travel_to, thanks!

@pftg
Copy link
Contributor

@pftg pftg commented Dec 3, 2013

@cbartlett please squash commits

@senny
Copy link
Member

@senny senny commented Dec 3, 2013

@pftg first one is a refactoring of existing code. I think it's fine to keep them separated.

@cbartlett
Copy link
Contributor Author

@cbartlett cbartlett commented Dec 3, 2013

@pftg I rebased all my related commits together before i pushed. The other commit wasn't related to my addition.

@carlosantoniodasilva
Copy link
Member

@carlosantoniodasilva carlosantoniodasilva commented Dec 3, 2013

Looks good, thanks 👍

@pftg
Copy link
Contributor

@pftg pftg commented Dec 3, 2013

I see, sorry for worries

@cbartlett
Copy link
Contributor Author

@cbartlett cbartlett commented Dec 3, 2013

@pftg ничего страшного)

carlosantoniodasilva added a commit that referenced this pull request Dec 3, 2013
Add support for localized date references
@carlosantoniodasilva carlosantoniodasilva merged commit 1441961 into rails:master Dec 3, 2013
1 check was pending
1 check was pending
default The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.