Java Code Examples for org.apache.calcite.avatica.util.DateTimeUtils#unixTimestampFloor()
The following examples show how to use
org.apache.calcite.avatica.util.DateTimeUtils#unixTimestampFloor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RexInterpreter.java From Quicksql with MIT License | 6 votes |
private Comparable ceil(RexCall call, List<Comparable> values) { if (values.get(0) == N) { return N; } final Long v = (Long) values.get(0); final TimeUnitRange unit = (TimeUnitRange) values.get(1); switch (unit) { case YEAR: case MONTH: switch (call.getKind()) { case FLOOR: return DateTimeUtils.unixTimestampFloor(unit, v); default: return DateTimeUtils.unixTimestampCeil(unit, v); } } final TimeUnitRange subUnit = subUnit(unit); for (long v2 = v;;) { final int e = DateTimeUtils.unixTimestampExtract(subUnit, v2); if (e == 0) { return v2; } v2 -= unit.startUnit.multiplier.longValue(); } }
Example 2
Source File: RexInterpreter.java From calcite with Apache License 2.0 | 6 votes |
private Comparable ceil(RexCall call, List<Comparable> values) { if (values.get(0) == N) { return N; } final Long v = (Long) values.get(0); final TimeUnitRange unit = (TimeUnitRange) values.get(1); switch (unit) { case YEAR: case MONTH: switch (call.getKind()) { case FLOOR: return DateTimeUtils.unixTimestampFloor(unit, v); default: return DateTimeUtils.unixTimestampCeil(unit, v); } } final TimeUnitRange subUnit = subUnit(unit); for (long v2 = v;;) { final int e = DateTimeUtils.unixTimestampExtract(subUnit, v2); if (e == 0) { return v2; } v2 -= unit.startUnit.multiplier.longValue(); } }