Skip to content

Commit

Permalink
[Bug] Fix the bug in from_date_format_str function (#6273)
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee authored Jul 21, 2021
1 parent 7771233 commit 02a00cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion be/src/runtime/datetime_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ bool DateTimeValue::from_date_format_str(const char* format, int format_len, con
(!strict_week_number && strict_week_number_year >= 0)) {
return false;
}
uint64_t days = calc_daynr(strict_week_number ? strict_week_number_year : _year, 1, 1);
uint64_t days = calc_daynr(strict_week_number ? strict_week_number_year : year, 1, 1);

uint8_t weekday_b = calc_weekday(days, sunday_first);

Expand Down
8 changes: 8 additions & 0 deletions be/test/runtime/datetime_value_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ TEST_F(DateTimeValueTest, from_date_format_str) {
value.to_string(str);
ASSERT_STREQ("2015-01-05 12:34:56", str);

// %T
format_str = "%W %U %Y";
value_str = "Tuesday 00 2002";
ASSERT_TRUE(value.from_date_format_str(format_str.c_str(), format_str.size(), value_str.c_str(),
value_str.size()));
value.to_string(str);
ASSERT_STREQ("2002-01-01", str);

// hour
format_str = "%Y-%m-%d %H %i %s";
value_str = "88-2-1 03 4 5";
Expand Down

0 comments on commit 02a00cd

Please sign in to comment.