Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ccat3z committed Sep 24, 2024
1 parent 31bb656 commit ee010e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
3 changes: 1 addition & 2 deletions velox/functions/lib/TimeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
35 changes: 17 additions & 18 deletions velox/functions/prestosql/tests/DateTimeFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<std::string, std::string>> 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"));
}

Expand Down

0 comments on commit ee010e0

Please sign in to comment.