-
Notifications
You must be signed in to change notification settings - Fork 22.1k
Add support for localized date references #12822
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
Conversation
|
/cc @pixeltrix |
activesupport/test/time_zone_test.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use travel_to to stub the current time: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/testing/time_helpers.rb#L43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to change test_today too.
|
@cbartlett can you provide a CHANGELOG entry as well - thanks |
|
@pixeltrix CHANGELOG added. |
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.
|
@senny @carlosantoniodasilva All done. Test update to use |
|
@cbartlett please squash commits |
|
@pftg first one is a refactoring of existing code. I think it's fine to keep them separated. |
|
@pftg I rebased all my related commits together before i pushed. The other commit wasn't related to my addition. |
|
Looks good, thanks 👍 |
|
I see, sorry for worries |
|
@pftg ничего страшного) |
Add support for localized date references
Ruby's
Dateclass automatically gives us#yesterday,#today, and#tomorrow. And ActiveSupport has a handyTime.zone.todayfor getting a localized version. But there was no localized version of#yesterdayor#tomorrow.This patch adds those methods.
Any thoughts on this? I think if we offer
#todayto mimic the behavior ofDate, perhaps we should also offer#tomorrowand#yesterday? I ran into the problem when localizing an app and converting a bunch ofDate.todayandDate.tomorrowusages.