Skip to content
New issue

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

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

Already on GitHub? # to your account

Faker Month Off-by-One Error when using I18n #1674

Closed
ryenski opened this issue Jul 31, 2019 · 6 comments · Fixed by #1675
Closed

Faker Month Off-by-One Error when using I18n #1674

ryenski opened this issue Jul 31, 2019 · 6 comments · Fixed by #1675

Comments

@ryenski
Copy link

ryenski commented Jul 31, 2019

Describe the bug

Faker's en.yml file doesn't include a nil value for the month_names array, which causes the months to be offset by one. This causes dates to be one month ahead when formatted.

To Reproduce

Describe the steps to reproduce the behavior.

without Faker...

irb(main):007:0> Date.today
=> Wed, 31 Jul 2019
irb(main):001:0> I18n.l(Date.today, format: :long)
=> "July 31, 2019"
irb(main):002:0> I18n.t("date.month_names")
=> [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

with faker...

irb(main):003:0> require 'faker'
=> true
irb(main):007:0> Date.today
=> Wed, 31 Jul 2019
irb(main):004:0> I18n.l(Date.today, format: :long)
=> "August 31, 2019"
irb(main):006:0> I18n.t("date.month_names")
=> ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

This problem is also described in spree/spree#2427

@ryenski ryenski changed the title Month Formatting Bug Faker Month Formatting Bug Jul 31, 2019
jutonz added a commit to jutonz/faker that referenced this issue Jul 31, 2019
@vbrazo
Copy link
Member

vbrazo commented Jul 31, 2019

@crispinheneise thanks for reporting 👍

@ryenski ryenski changed the title Faker Month Formatting Bug Faker Month Off-by-One Error when using I18n Jul 31, 2019
@vbrazo
Copy link
Member

vbrazo commented Jul 31, 2019

@crispinheneise @jutonz I know this can be a bit impactful, but I'd prefer to wait for other small bug fixes/minor enhancements before doing a minor release 2.1.0. We could do that in a few weeks.

Let me know if anyone disagrees with me. If this becomes a real big issue, we can accelerate the process.

@ryenski
Copy link
Author

ryenski commented Jul 31, 2019

It may not be an issue for some because Faker is typically not used in production. For me it was a breaking issue because every place where I18n.l was used began to display the wrong date, causing my test suite to fail.

@tconst
Copy link

tconst commented Jul 31, 2019

I found this after narrowing down the test suite failure to the faker gem update. It's not particularly obvious why or where the failure is coming from so I imagine it would cause some frustration.

@vbrazo vbrazo reopened this Jul 31, 2019
@vbrazo vbrazo closed this as completed Jul 31, 2019
@vbrazo
Copy link
Member

vbrazo commented Jul 31, 2019

I just did a small release. No frustration anymore. Let me know if you see anything else.

@ryenski
Copy link
Author

ryenski commented Aug 1, 2019

I found this after narrowing down the test suite failure to the faker gem update. It's not particularly obvious why or where the failure is coming from so I imagine it would cause some frustration.

@tconst Dependabot to the rescue. Dependabot had opened several PRs today, but the only one that failed CI was the faker upgrade. From there it was pretty easy to narrow it down.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants