-
Notifications
You must be signed in to change notification settings - Fork 37
Conversation
return kDateDay; | ||
} | ||
if (t.type == TokenType::kNumber) { | ||
if (t.val < 1 || t.val > 31) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inaccurate judgment, need to judge with the month.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only limit checking, when create date will check the date validation.
There are two problems:
|
|
|
||
// TODO(shylock) support weeks/days format when support the convertion | ||
// The state of current parser | ||
enum State { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used for array index.
tokens_.emplace_back(t); | ||
digits.clear(); | ||
} | ||
} else if (kTimeDelimiter == *c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's more intuitive to use switch cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a condition isdigit
.
// State, ShiftMap | ||
{kInitial, | ||
[](Token, Token, Context &ctx) -> StatusOr<State> { | ||
if (ctx.type == ExpectType::kDateTime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to use a hashmap here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array is more efficient.
nebula::time::TimeParser parser; | ||
auto result = parser.parseDateTime("2019-01-03T22:22:3.2333"); | ||
ASSERT_TRUE(result.ok()) << result.status(); | ||
EXPECT_EQ(nebula::DateTime(2019, 1, 3, 22, 22, 3, 2333), result.value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be 233300 microseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be a utc time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's just the utc time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. The process of fraction of second had be corrected.
namespace nebula { | ||
namespace time { | ||
|
||
/*static*/ const std::vector<TimeParser::Component> TimeParser::dateTimeStates = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try to use FSM to solve these states transfer issue, that's powerful tool for string parser, need not any branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about your meaning. Could you detail the structure about the FSM you means, and how to replace the branches.
} | ||
|
||
std::string DateTime::toString() const { | ||
auto microsecStr = folly::stringPrintf("%.9f", static_cast<uint32_t>(microsec) / 1000000.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we keep 9 digits for ms instead of 6? Nebula's time precision is different from openCypher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference? They are both fraction of second.
Move to vesoft-inc/nebula#2770 |
No description provided.