Fixed wrong toISOWeek result for 1970 year

This commit is contained in:
Alexey Milovidov 2019-04-12 02:21:37 +03:00
parent 79d2f1f034
commit 1610bcca89
3 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,15 @@
0000-00-00 1 1970
1970-01-02 1 1970
1970-01-03 1 1970
1970-01-04 1 1970
1970-01-05 2 1970
1970-01-06 2 1970
1970-01-07 2 1970
1970-01-08 2 1970
1970-01-09 2 1970
1970-01-10 2 1970
1970-01-11 2 1970
1970-01-12 3 1970
1970-01-13 3 1970
1970-01-14 3 1970
1970-01-15 3 1970

View File

@ -0,0 +1 @@
SELECT toDate('1970-01-01') + number AS d, toISOWeek(d), toISOYear(d) FROM numbers(15);

View File

@ -371,7 +371,7 @@ public:
/// The week number 1 is the first week in year that contains 4 or more days (that's more than half). /// The week number 1 is the first week in year that contains 4 or more days (that's more than half).
inline unsigned toISOWeek(DayNum d) const inline unsigned toISOWeek(DayNum d) const
{ {
return 1 + (toFirstDayNumOfWeek(d) - toFirstDayNumOfISOYear(d)) / 7; return 1 + DayNum(toFirstDayNumOfWeek(d) - toFirstDayNumOfISOYear(d)) / 7;
} }
inline unsigned toISOWeek(time_t t) const inline unsigned toISOWeek(time_t t) const