imay commented on a change in pull request #1598: Time zone related be function
URL: https://github.com/apache/incubator-doris/pull/1598#discussion_r312721642
##########
File path: be/src/runtime/datetime_value.cpp
##########
@@ -1524,43 +1524,42 @@ bool DateTimeValue::date_add_interval(const
TimeInterval& interval, TimeUnit uni
return true;
}
-int DateTimeValue::unix_timestamp() const {
- int64_t days = daynr() - calc_daynr(1970, 1, 1);
- if (days < 0) {
- return 0;
- }
- int64_t seconds = days * 86400 + _hour * 3600 + _minute * 60 + _second;
- if (seconds > std::numeric_limits<int>::max()) {
- return 0;
- }
- // TODO(zc): we only support Beijing Timezone, so minus 28800
- seconds -= 28800;
- if (seconds < 0) {
- return 0;
- }
- return seconds;
-}
-
-bool DateTimeValue::from_unixtime(int64_t seconds) {
- if (seconds < 0) {
+int64_t DateTimeValue::unix_timestamp(const std::string& timezone) const {
+ boost::local_time::time_zone_ptr local_time_zone =
TimezoneDatabase::find_timezone(timezone);
+ if (local_time_zone == nullptr) {
return false;
Review comment:
unix_timestamp's return type is int64_t, it is better not to return `false`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]