提交 53865d28 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use more constants in IntervalOperation

上级 cc90f217
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
package org.h2.expression; package org.h2.expression;
import static org.h2.util.DateTimeUtils.NANOS_PER_DAY; import static org.h2.util.DateTimeUtils.NANOS_PER_DAY;
import static org.h2.util.DateTimeUtils.NANOS_PER_HOUR;
import static org.h2.util.DateTimeUtils.NANOS_PER_MINUTE;
import static org.h2.util.DateTimeUtils.absoluteDayFromDateValue; import static org.h2.util.DateTimeUtils.absoluteDayFromDateValue;
import static org.h2.util.DateTimeUtils.dateAndTimeFromValue; import static org.h2.util.DateTimeUtils.dateAndTimeFromValue;
import static org.h2.util.DateTimeUtils.dateTimeToValue; import static org.h2.util.DateTimeUtils.dateTimeToValue;
...@@ -168,8 +170,8 @@ public class IntervalOperation extends Expression { ...@@ -168,8 +170,8 @@ public class IntervalOperation extends Expression {
if (negative) { if (negative) {
diff = -diff; diff = -diff;
} }
return ValueInterval.from(IntervalQualifier.HOUR_TO_SECOND, negative, diff / 3_600_000_000_000L, return ValueInterval.from(IntervalQualifier.HOUR_TO_SECOND, negative, diff / NANOS_PER_HOUR,
diff % 3_600_000_000_000L); diff % NANOS_PER_HOUR);
} else if (lType == Value.DATE && rType == Value.DATE) { } else if (lType == Value.DATE && rType == Value.DATE) {
long diff = absoluteDayFromDateValue(((ValueDate) l).getDateValue()) long diff = absoluteDayFromDateValue(((ValueDate) l).getDateValue())
- absoluteDayFromDateValue(((ValueDate) r).getDateValue()); - absoluteDayFromDateValue(((ValueDate) r).getDateValue());
...@@ -184,7 +186,7 @@ public class IntervalOperation extends Expression { ...@@ -184,7 +186,7 @@ public class IntervalOperation extends Expression {
l = l.convertTo(Value.TIMESTAMP_TZ); l = l.convertTo(Value.TIMESTAMP_TZ);
r = r.convertTo(Value.TIMESTAMP_TZ); r = r.convertTo(Value.TIMESTAMP_TZ);
diff = diff.add(BigInteger.valueOf((((ValueTimestampTimeZone) r).getTimeZoneOffsetMins() diff = diff.add(BigInteger.valueOf((((ValueTimestampTimeZone) r).getTimeZoneOffsetMins()
- ((ValueTimestampTimeZone) l).getTimeZoneOffsetMins()) * 60_000_000_000L)); - ((ValueTimestampTimeZone) l).getTimeZoneOffsetMins()) * NANOS_PER_MINUTE));
} }
return IntervalUtils.intervalFromAbsolute(IntervalQualifier.DAY_TO_SECOND, diff); return IntervalUtils.intervalFromAbsolute(IntervalQualifier.DAY_TO_SECOND, diff);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论