-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Formatter Gives correct year for dates near start/end of Year #40410
Merged
adam-james-v
merged 1 commit into
master
from
bugfix-40306-correct-year-for-dates-near-start-or-end-of-year
Mar 21, 2024
Merged
Formatter Gives correct year for dates near start/end of Year #40410
adam-james-v
merged 1 commit into
master
from
bugfix-40306-correct-year-for-dates-near-start-or-end-of-year
Mar 21, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes: #40306 Our datetime formatter relies on the `java-time.api`, for which there are many different, sometimes confusing, formatter patterns: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatterBuilder.html#appendPattern-java.lang.String- In this case, 'YYYY' is a week-of-year style year, which calculates which week a date falls into before returning the year. Sometimes days near the start/end of a year will fall into a week in the wrong year. For example, apparently 2023-12-31 falls into the 1st week of 2024, which probably not the year you'd expect to see. What we probably do want is 'yyyy' which calculates what day of the year the date is and then returns the year based off of that instead of the week number. For an explanation, you can check out this SO answer: https://stackoverflow.com/a/46395342 provides an explanation.
adam-james-v
added
the
backport
Automatically create PR on current release branch on merge
label
Mar 20, 2024
|
bshepherdson
approved these changes
Mar 21, 2024
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.
See my commentary on Slack about the long-term fate of this code.
But this specific change LGTM as a patch to the current state.
adam-james-v
deleted the
bugfix-40306-correct-year-for-dates-near-start-or-end-of-year
branch
March 21, 2024 15:09
@adam-james-v Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
github-actions bot
pushed a commit
that referenced
this pull request
Mar 21, 2024
Fixes: #40306 Our datetime formatter relies on the `java-time.api`, for which there are many different, sometimes confusing, formatter patterns: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatterBuilder.html#appendPattern-java.lang.String- In this case, 'YYYY' is a week-of-year style year, which calculates which week a date falls into before returning the year. Sometimes days near the start/end of a year will fall into a week in the wrong year. For example, apparently 2023-12-31 falls into the 1st week of 2024, which probably not the year you'd expect to see. What we probably do want is 'yyyy' which calculates what day of the year the date is and then returns the year based off of that instead of the week number. For an explanation, you can check out this SO answer: https://stackoverflow.com/a/46395342 provides an explanation.
metabase-bot bot
added a commit
that referenced
this pull request
Mar 21, 2024
#40450) Fixes: #40306 Our datetime formatter relies on the `java-time.api`, for which there are many different, sometimes confusing, formatter patterns: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatterBuilder.html#appendPattern-java.lang.String- In this case, 'YYYY' is a week-of-year style year, which calculates which week a date falls into before returning the year. Sometimes days near the start/end of a year will fall into a week in the wrong year. For example, apparently 2023-12-31 falls into the 1st week of 2024, which probably not the year you'd expect to see. What we probably do want is 'yyyy' which calculates what day of the year the date is and then returns the year based off of that instead of the week number. For an explanation, you can check out this SO answer: https://stackoverflow.com/a/46395342 provides an explanation. Co-authored-by: adam-james <21064735+adam-james-v@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport
Automatically create PR on current release branch on merge
.Team/DashViz
Dashboard and Viz team
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #40306
Our datetime formatter relies on the
java-time.api
, for which there are many different, sometimes confusing, formatter patterns: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatterBuilder.html#appendPattern-java.lang.String-In this case, 'YYYY' is a week-of-year style year, which calculates which week a date falls into before returning the year. Sometimes days near the start/end of a year will fall into a week in the wrong year.
For example, apparently 2023-12-31 falls into the 1st week of 2024, which probably not the year you'd expect to see. What we probably do want is 'yyyy' which calculates what day of the year the date is and then returns the year based off of that instead of the week number.
For an explanation, you can check out this SO answer: https://stackoverflow.com/a/46395342 provides an explanation.
I've opted just to do a
str/replace
in the post-processing of our formatter because many existing cards may have column formatting entries in their viz-settings with the 'YYYY' format.