Skip to content

Conversation

@jenno-verdonck
Copy link
Contributor

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

int lower = Integer.valueOf((dateUnit) / (_range)) * (_range);
int upper = lower + _range;
String outputDate = "[" + lower + ", " + upper + "[";
String outputDate = "[" + (lower+1) + ", " + (upper+1) + "[";

Check warning

Code scanning / PMD

Consider simply returning the value vs storing it in local variable 'solution'

Consider simply returning the value vs storing it in local variable 'outputDate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant