I see that Y -> year of “Week of Year” whereas y or yyyy -> year, but do not understand the difference. I haven’t been able to test using y and assume it would fix the issue, but would like to understand what ‘year of “Week of Year”’ is exactly. Can anyone enlighten me on this?
Working with dates is a really complex thing, so for ISO 8601 they use a concept of date calculation based on weeks. Ubuntu Man Pages put it this way:
ISO 8601 week dates
%G, %g, and %V yield values calculated from the week-based year defined by the ISO 8601
standard. In this system, weeks start on a Monday, and are numbered from 01, for the
first week, up to 52 or 53, for the last week. Week 1 is the first week where four or
more days fall within the new year (or, synonymously, week 01 is: the first week of the
year that contains a Thursday; or, the week that has 4 January in it). When three of
fewer days of the first calendar week of the new year fall within that year, then the ISO
8601 week-based system counts those days as part of week 53 of the preceding year. For
example, 1 January 2010 is a Friday, meaning that just three days of that calendar week
fall in 2010. Thus, the ISO 8601 week-based system considers these days to be part of
week 53 (%V) of the year 2009 (%G); week 01 of ISO 8601 year 2010 starts on Monday, 4
A clear spot on the problem you pointed can be read on Wikipedia:
The first ISO week of a year may have up to three days that are actually in the Gregorian calendar year that is ending; if three, they are Monday, Tuesday and Wednesday.
So, 2020-12-28 was a Monday, belonging to the week year of 2021.