This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 02a00cd [Bug] Fix the bug in `from_date_format_str` function (#6273)
02a00cd is described below
commit 02a00cdf358f70e86235e991f91702b0655279e5
Author: HappenLee <[email protected]>
AuthorDate: Tue Jul 20 23:31:37 2021 -0500
[Bug] Fix the bug in `from_date_format_str` function (#6273)
---
be/src/runtime/datetime_value.cpp | 2 +-
be/test/runtime/datetime_value_test.cpp | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/be/src/runtime/datetime_value.cpp
b/be/src/runtime/datetime_value.cpp
index b440e20..49b84b3 100644
--- a/be/src/runtime/datetime_value.cpp
+++ b/be/src/runtime/datetime_value.cpp
@@ -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);
diff --git a/be/test/runtime/datetime_value_test.cpp
b/be/test/runtime/datetime_value_test.cpp
index edf22fa..da0053a 100644
--- a/be/test/runtime/datetime_value_test.cpp
+++ b/be/test/runtime/datetime_value_test.cpp
@@ -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";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]