提交 8f5800e8 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use constant names without a class name

上级 2c15823a
...@@ -1887,34 +1887,34 @@ public class Function extends Expression implements FunctionCall { ...@@ -1887,34 +1887,34 @@ public class Function extends Expression implements FunctionCall {
calendar.get(Calendar.DAY_OF_WEEK), calendar.get(Calendar.DAY_OF_WEEK),
calendar.get(Calendar.MILLISECOND)); calendar.get(Calendar.MILLISECOND));
switch (field) { switch (field) {
case Function.MILLISECOND: case MILLISECOND:
return t2 - t1; return t2 - t1;
case Function.SECOND: case SECOND:
case Function.MINUTE: case MINUTE:
case Function.HOUR: case HOUR:
case Function.DAY_OF_YEAR: case DAY_OF_YEAR:
case Function.WEEK: { case WEEK: {
// first 'normalize' the numbers so both are not negative // first 'normalize' the numbers so both are not negative
long hour = 60 * 60 * 1000; long hour = 60 * 60 * 1000;
long add = Math.min(t1 / hour * hour, t2 / hour * hour); long add = Math.min(t1 / hour * hour, t2 / hour * hour);
t1 -= add; t1 -= add;
t2 -= add; t2 -= add;
switch (field) { switch (field) {
case Function.SECOND: case SECOND:
return t2 / 1000 - t1 / 1000; return t2 / 1000 - t1 / 1000;
case Function.MINUTE: case MINUTE:
return t2 / (60 * 1000) - t1 / (60 * 1000); return t2 / (60 * 1000) - t1 / (60 * 1000);
case Function.HOUR: case HOUR:
return t2 / hour - t1 / hour; return t2 / hour - t1 / hour;
case Function.DAY_OF_YEAR: case DAY_OF_YEAR:
return t2 / (hour * 24) - t1 / (hour * 24); return t2 / (hour * 24) - t1 / (hour * 24);
case Function.WEEK: case WEEK:
return t2 / (hour * 24 * 7) - t1 / (hour * 24 * 7); return t2 / (hour * 24 * 7) - t1 / (hour * 24 * 7);
default: default:
throw DbException.throwInternalError("field:" + field); throw DbException.throwInternalError("field:" + field);
} }
} }
case Function.DAY_OF_MONTH: case DAY_OF_MONTH:
return t2 / (24 * 60 * 60 * 1000) - t1 / (24 * 60 * 60 * 1000); return t2 / (24 * 60 * 60 * 1000) - t1 / (24 * 60 * 60 * 1000);
default: default:
break; break;
...@@ -1927,9 +1927,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -1927,9 +1927,9 @@ public class Function extends Expression implements FunctionCall {
int year2 = calendar.get(Calendar.YEAR); int year2 = calendar.get(Calendar.YEAR);
int month2 = calendar.get(Calendar.MONTH); int month2 = calendar.get(Calendar.MONTH);
int result = year2 - year1; int result = year2 - year1;
if (field == Function.MONTH) { if (field == MONTH) {
return 12 * result + (month2 - month1); return 12 * result + (month2 - month1);
} else if (field == Function.YEAR) { } else if (field == YEAR) {
return result; return result;
} else { } else {
throw DbException.getUnsupportedException("DATEDIFF " + part); throw DbException.getUnsupportedException("DATEDIFF " + part);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论