Skip to content

Commit

Permalink
Confirm test pass
Browse files Browse the repository at this point in the history
Signed-off-by: JaySon-Huang <jayson.hjs@gmail.com>
  • Loading branch information
JaySon-Huang committed May 24, 2021
1 parent afd8901 commit 0f70f26
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dbms/src/Common/MyTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,15 +1364,16 @@ static bool parseTime12Hour(MyDateTimeParser::Context & ctx, MyTimeBase & time)
int meridiem = 0; // 0 - invalid, 1 - am, 2 - pm
if (state = skipWhitespaces(); state != ParseState::NORMAL)
return state;
// "AM"/"PM" must be parsed as a single element
// "11:13:56a" is an invalid input for "%r".
if (auto size_to_end = ctx.view.size - temp_pos; size_to_end < 2)
return ParseState::FAIL;
if (toLowerIfAlphaASCII(ctx.view.data[temp_pos]) == 'a')
meridiem = 1;
else if (toLowerIfAlphaASCII(ctx.view.data[temp_pos]) == 'p')
meridiem = 2;
temp_pos += 1; // move forward

if (state = checkIfEnd(); state != ParseState::NORMAL)
return state;
if (toLowerIfAlphaASCII(ctx.view.data[temp_pos]) != 'm')
if (toLowerIfAlphaASCII(ctx.view.data[temp_pos + 1]) != 'm')
meridiem = 0;
switch (meridiem)
{
Expand All @@ -1384,7 +1385,7 @@ static bool parseTime12Hour(MyDateTimeParser::Context & ctx, MyTimeBase & time)
time.hour += 12;
break;
}
temp_pos += 1; // move forward
temp_pos += 2; // move forward
return ParseState::NORMAL;
};
if (auto state = tryParse(); state == ParseState::FAIL)
Expand Down

0 comments on commit 0f70f26

Please sign in to comment.