提交 4fe7e5a9 authored 作者: Stéphane Eintrazi's avatar Stéphane Eintrazi

add comment

上级 e9804dc9
...@@ -3000,7 +3000,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -3000,7 +3000,7 @@ public class Function extends Expression implements FunctionCall {
long[] fieldDateAndTime = DateTimeUtils.dateAndTimeFromValue(value); long[] fieldDateAndTime = DateTimeUtils.dateAndTimeFromValue(value);
long dateValue = fieldDateAndTime[0]; long dateValue = fieldDateAndTime[0];
long timeNanosRetrieved = fieldDateAndTime[1]; long timeNanosRetrieved = fieldDateAndTime[1];
// Variable used to the time in nanoseconds of the date truncated. // Variable used to the time in nanoseconds of the date truncated.
Long timeNanos = null; Long timeNanos = null;
...@@ -3008,7 +3008,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -3008,7 +3008,7 @@ public class Function extends Expression implements FunctionCall {
// number of time unit 'HOUR' in '15:14:13' is '15'. Then convert the // number of time unit 'HOUR' in '15:14:13' is '15'. Then convert the
// result to nanoseconds. // result to nanoseconds.
switch (timeUnit) { switch (timeUnit) {
case MICROSECOND: case MICROSECOND:
long nanoInMicroSecond = 1_000l; long nanoInMicroSecond = 1_000l;
...@@ -3017,7 +3017,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -3017,7 +3017,7 @@ public class Function extends Expression implements FunctionCall {
break; break;
case MILLISECOND: case MILLISECOND:
long nanoInMilliSecond = 1_000_000l; long nanoInMilliSecond = 1_000_000l;
long milliseconds = timeNanosRetrieved / nanoInMilliSecond; long milliseconds = timeNanosRetrieved / nanoInMilliSecond;
timeNanos = milliseconds * nanoInMilliSecond; timeNanos = milliseconds * nanoInMilliSecond;
...@@ -3038,19 +3038,21 @@ public class Function extends Expression implements FunctionCall { ...@@ -3038,19 +3038,21 @@ public class Function extends Expression implements FunctionCall {
break; break;
case HOUR: case HOUR:
long nanoInHour = 3_600_000_000_000l; long nanoInHour = 3_600_000_000_000l;
long hours = timeNanosRetrieved / nanoInHour; long hours = timeNanosRetrieved / nanoInHour;
timeNanos = hours * nanoInHour; timeNanos = hours * nanoInHour;
break; break;
case DAY_OF_MONTH: case DAY_OF_MONTH:
timeNanos = 0l; timeNanos = 0l;
break; break;
case WEEK: case WEEK:
// Use Calendar to retrieve the first day of the week and convert
// the date to a dateValue
Date currentDate = DateTimeUtils.convertDateValueToDate(dateValue); Date currentDate = DateTimeUtils.convertDateValueToDate(dateValue);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate); calendar.setTime(currentDate);
...@@ -3059,9 +3061,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -3059,9 +3061,9 @@ public class Function extends Expression implements FunctionCall {
dateValue = valueTimestamp.getDateValue(); dateValue = valueTimestamp.getDateValue();
timeNanos = 0l; timeNanos = 0l;
break; break;
} }
if(timeNanos == null) { if (timeNanos == null) {
// Return an exception in the timeUnit is not recognized // Return an exception in the timeUnit is not recognized
throw DbException.getUnsupportedException(timeUnitStr); throw DbException.getUnsupportedException(timeUnitStr);
...@@ -3072,8 +3074,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -3072,8 +3074,7 @@ public class Function extends Expression implements FunctionCall {
// Case we create a timestamp with timezone with the dateValue and // Case we create a timestamp with timezone with the dateValue and
// timeNanos computed. // timeNanos computed.
ValueTimestampTimeZone vTmp = (ValueTimestampTimeZone) value; ValueTimestampTimeZone vTmp = (ValueTimestampTimeZone) value;
result = ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, timeNanos, result = ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, timeNanos, vTmp.getTimeZoneOffsetMins());
vTmp.getTimeZoneOffsetMins());
} else { } else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论