提交 eb46908e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix merge once again

上级 1409942c
......@@ -16,7 +16,6 @@ import java.util.Locale;
import java.util.TimeZone;
import org.h2.api.ErrorCode;
import org.h2.engine.Mode;
import org.h2.expression.Function;
import org.h2.message.DbException;
import org.h2.value.Value;
import org.h2.value.ValueDate;
......@@ -25,7 +24,6 @@ import org.h2.value.ValueTime;
import org.h2.value.ValueTimestamp;
import org.h2.value.ValueTimestampTimeZone;
/**
* This utility class contains time conversion functions.
* <p>
......@@ -625,52 +623,6 @@ public class DateTimeUtils {
return ValueTimestamp.fromDateValueAndNanos(dateValue, timeNanos);
}
/**
* Get the specified field of a date, however with years normalized to
* positive or negative, and month starting with 1.
*
* @param date the date value
* @param field the field type, see {@link Function} for constants
* @return the value
*/
public static int getDatePart(Value date, int field) {
long[] a = dateAndTimeFromValue(date);
long dateValue = a[0];
long timeNanos = a[1];
switch (field) {
case Function.YEAR:
return yearFromDateValue(dateValue);
case Function.MONTH:
return monthFromDateValue(dateValue);
case Function.DAY_OF_MONTH:
return dayFromDateValue(dateValue);
case Function.HOUR:
return (int) (timeNanos / 3_600_000_000_000L % 24);
case Function.MINUTE:
return (int) (timeNanos / 60_000_000_000L % 60);
case Function.SECOND:
return (int) (timeNanos / 1_000_000_000 % 60);
case Function.MILLISECOND:
return (int) (timeNanos / 1_000_000 % 1_000);
case Function.DAY_OF_YEAR:
return getDayOfYear(dateValue);
case Function.DAY_OF_WEEK:
return getSundayDayOfWeek(dateValue);
case Function.WEEK:
GregorianCalendar gc = getCalendar();
return getWeekOfYear(dateValue, gc.getFirstDayOfWeek() - 1, gc.getMinimalDaysInFirstWeek());
case Function.QUARTER:
return (monthFromDateValue(dateValue) - 1) / 3 + 1;
case Function.ISO_YEAR:
return getIsoWeekYear(dateValue);
case Function.ISO_WEEK:
return getIsoWeekOfYear(dateValue);
case Function.ISO_DAY_OF_WEEK:
return getIsoDayOfWeek(dateValue);
}
throw DbException.getUnsupportedException("getDatePart(" + date + ", " + field + ')');
}
/**
* Get the year (positive or negative) from a calendar.
*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论