Format fixes in HierarchyBuilderDate #441
Open
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.
This pull request fixes two bugs in the HierarchyBuilder for date properties.
The first bug has to do with the "WEEK_YEAR" granularity. This granularity uses the "week-of-week-based-year" format in the Java DateTimeFormatter. This formats the week to a number with a maximum of 52 However, a year can contain a partial 53th week when the year doesn't end in a sunday. This 53th week gets the number 1 of the next year as "week-of-week-based-year" value. This currently causes dates such as 01/01/2019 and 31/12/2019 both to be generalized to 01/2019 while being almost a year apart. The pull request fixes this by replacing the "yyyy" ("year-of-era") format with the "YYYY" ("week-based-year") causing 01/01/2019 and 31/12/2019 to be generalized to a different value. Namely 01/2019 and 01/2020.
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
The second bug has to do with the definitions of "DECADE", "CENTURY" and "MILLENNIUM". All these units currently generalize the year to ranges where the first included year ends with a 0. However decades, centuries and millenniums are defined to start with the year ending in 1 (example: 21th-century includes all years starting from 2001 up and to including 2100). The pull request fixes this by changing the generalize function increasing the bound by 1 and shifting when a certain range is used.
https://en.wikipedia.org/wiki/Century