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

Return correct date in ActiveModel for time to date conversions #29651

Merged
merged 1 commit into from Feb 18, 2019

Conversation

@Sayanc93
Copy link
Contributor

@Sayanc93 Sayanc93 commented Jul 1, 2017

time.to_date conversion happens considering leap years in Ruby.
So a conversion of Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"}) or 0001-01-01 00:00:00 UTC results in saving the date in DB as Mon, 03 Jan 0001.
Which might seem weird on the user level, hence falling back to parsing on string level resolves this data mismatch respecting the parameters passed
Fixes #28521

@rails-bot
Copy link

@rails-bot rails-bot commented Jul 1, 2017

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

activemodel/lib/active_model/type/date.rb Outdated Show resolved Hide resolved
activemodel/CHANGELOG.md Outdated Show resolved Hide resolved
activemodel/CHANGELOG.md Outdated Show resolved Hide resolved
@Sayanc93 Sayanc93 force-pushed the return-correct-date branch from fdbb7c2 to b544e7c Jul 1, 2017
@Sayanc93 Sayanc93 force-pushed the return-correct-date branch 2 times, most recently from 15fcba3 to 19238e6 Jul 21, 2017
@Sayanc93
Copy link
Contributor Author

@Sayanc93 Sayanc93 commented Aug 21, 2017

r? @kamipo

@rails-bot rails-bot assigned kamipo and unassigned schneems Aug 21, 2017
time.to_date conversion happens considering leap years
so a conversion of "Day.new({'day(1i)'=>'1', 'day(2i)'=>'1', 'day(3i)'=>'1'})" results in saving the date as Mon, 03 Jan 0001
which might seem weird on the user level, hence falling back to parsing on string level resolves this data mismatch
Fixes rails#28521
@Sayanc93 Sayanc93 force-pushed the return-correct-date branch from 19238e6 to eb73dfc Dec 17, 2017
@kamipo kamipo merged commit eb73dfc into rails:master Feb 18, 2019
1 of 2 checks passed
kamipo added a commit that referenced this issue Feb 18, 2019
Return correct date in ActiveModel for time to date conversions
kamipo added a commit that referenced this issue Feb 19, 2019
Return correct date in ActiveModel for time to date conversions
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.

5 participants