Return correct date in ActiveModel for time to date conversions - #29651
Conversation
|
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. |
fdbb7c2 to
b544e7c
Compare
15fcba3 to
19238e6
Compare
|
r? @kamipo |
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
19238e6 to
eb73dfc
Compare
Return correct date in ActiveModel for time to date conversions
Return correct date in ActiveModel for time to date conversions
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