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
fix(material/datepicker): fix handling of short years #20709
Conversation
39ddaf5
to
7066d31
Compare
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.
I think that this is basically the same as the old fix, except that the previous approach had the small optimization that we only mutated the new date if we detect the edge case for years 0 to 99, whereas this approach does it every time. My concern is that since we're setting the hours/minutes/seconds to 0, we might break some people that depended on the old behavior.
If we only wanted to fix the tests, we could create the date as February 1st, instead of January 1st.
I think the old behavior set the hour/m/s/ms to 0 anyways? If you construct a date without specifying those 0 is assumed. I think this does differ from the old way. The old way you overwrote only the year, and my theory is that for locales where the timezone offset has changed over time this was leading to dates that were slightly off. At the very least this seems to pass on CI where the old approach was regularly failing |
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.
My hesitation comes from the fact this is used anywhere we interact with a date, not just when it's formatted which could break people in subtle ways, whereas the previous fix only affected formatting. Let's see how it goes during the presubmit and we can adjust the test, instead of changing the logic, if it ends up breaking too many targets.
I still don't quite understand your concern. I modified the same 2 methods your change did: |
I think that the changes are fine, but at a glance it isn't obvious why they would be fixing the test, considering that they're setting the same values as the defaults. Looking through it again, I have a theory about what might've been throwing it off. Note how |
(cherry picked from commit b3f1fb3)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This should hopefully fix test flakiness introduced by dd49fa6. The previous fix seems to sometimes report an incorrect date based on the time zone the test runs in