diff --git a/velox/functions/lib/TimeUtils.h b/velox/functions/lib/TimeUtils.h index 3eba3f2aa3860..485df173aaf6b 100644 --- a/velox/functions/lib/TimeUtils.h +++ b/velox/functions/lib/TimeUtils.h @@ -152,8 +152,7 @@ int32_t getWeekYear( uint32_t d, uint32_t firstDayOfWeek, uint32_t minimalDaysInFirstWeek) { - auto ymd = - date::year_month_day(date::year(y), date::month(m), date::day(d)); + auto ymd = date::year_month_day(date::year(y), date::month(m), date::day(d)); auto weekday = date::weekday(ymd).c_encoding(); auto firstDayOfTheYear = date::year_month_day(ymd.year(), date::month(1), date::day(1)); diff --git a/velox/functions/prestosql/tests/DateTimeFunctionsTest.cpp b/velox/functions/prestosql/tests/DateTimeFunctionsTest.cpp index 01e1f5ba5005c..ce467319b2688 100644 --- a/velox/functions/prestosql/tests/DateTimeFunctionsTest.cpp +++ b/velox/functions/prestosql/tests/DateTimeFunctionsTest.cpp @@ -3368,24 +3368,23 @@ TEST_F(DateTimeFunctionsTest, dateFormat) { parseTimestamp("-2000-02-29 00:00:00.987"), "%Y-%m-%d %H:%i:%s.%f")); const std::vector> weekyears = { - {"2017-01-01","2016"}, - {"2017-12-31","2017"}, - {"2018-01-01","2018"}, - {"2018-12-31","2019"}, - {"2019-01-01","2019"}, - {"2019-12-30","2020"}, - {"2019-12-31","2020"}, - {"2020-01-01","2020"}, - {"2020-12-31","2020"}, - {"2021-01-01","2020"}, - {"2021-01-02","2020"}, - {"2021-01-03","2020"}, - {"2021-12-31","2021"}, - {"2022-01-01","2021"}, - {"2022-01-02","2021"}, - {"2022-12-31","2022"} - }; - for (const auto & [date, weekyear] : weekyears) { + {"2017-01-01", "2016"}, + {"2017-12-31", "2017"}, + {"2018-01-01", "2018"}, + {"2018-12-31", "2019"}, + {"2019-01-01", "2019"}, + {"2019-12-30", "2020"}, + {"2019-12-31", "2020"}, + {"2020-01-01", "2020"}, + {"2020-12-31", "2020"}, + {"2021-01-01", "2020"}, + {"2021-01-02", "2020"}, + {"2021-01-03", "2020"}, + {"2021-12-31", "2021"}, + {"2022-01-01", "2021"}, + {"2022-01-02", "2021"}, + {"2022-12-31", "2022"}}; + for (const auto& [date, weekyear] : weekyears) { EXPECT_EQ(weekyear, dateFormat(parseTimestamp(date), "%x")); }