-
Notifications
You must be signed in to change notification settings - Fork 37
Support to get attribute of date/time/datetime. #586
Conversation
static Value getDateAttr(const Date &d, const std::string &prop) { | ||
auto lowerProp = boost::algorithm::to_lower_copy(prop); | ||
if (lowerProp == "year") { | ||
return d.year; |
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.
Don't you need to cast the type 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.
Why need cast?
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 not same as above getDateTimeAttr function.
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 datetime is bitfield, so need cast to fit the Value constructor.
static Value getTimeAttr(const Time &t, const std::string &prop) { | ||
auto lowerProp = boost::algorithm::to_lower_copy(prop); | ||
if (lowerProp == "hour") { | ||
return t.hour; |
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.
ditto
We shouldn't process the bad null different with null, they are all null in computation.