Description
https://forums.couchbase.com/t/date-trunc-str-with-week-not-working-in-analytics-query/35794
boolean trunc(boolean typeWithTimezone, long chrononIn, int timeZoneOffset, TimeZone timeZone, |
AMutableInt64 chrononOut, AMutableInt32 timeZoneOffsetOut, TimeZoneHelper tzHelper) {
|
GregorianCalendarSystem cal = GregorianCalendarSystem.getInstance();
|
long chrononInAtTz = typeWithTimezone ? cal.adjustChrononByTimezone(chrononIn, timeZoneOffset) : chrononIn; |
|
int year = cal.getYear(chrononInAtTz); |
int month = cal.getMonthOfYear(chrononInAtTz, year); |
int day = cal.getDayOfMonthYear(chrononInAtTz, year, month); |
int hour = cal.getHourOfDay(chrononInAtTz); |
int minute = cal.getMinOfHour(chrononInAtTz); |
int second = cal.getSecOfMin(chrononInAtTz); |
int millis = cal.getMillisOfSec(chrononInAtTz); |
|
switch (this) { |
case MILLENNIUM: |
case CENTURY: |
case DECADE: |
int y = monthsDuration / GregorianCalendarSystem.MONTHS_IN_A_YEAR; |
year = year / y * y;
|
// fall thru to 'YEAR' |
case YEAR: |
month = 1; |
// fall thru to 'QUARTER' |
case QUARTER: |
month = ((month - 1) / QUARTER.monthsDuration * QUARTER.monthsDuration) + 1; |
// fall thru to 'MONTH' |
case MONTH: |
day = 1; |
// fall thru to 'DAY' |
case DAY: |
hour = 0; |
// fall thru to 'HOUR' |
case HOUR: |
minute = 0; |
// fall thru to 'MINUTE' |
case MINUTE: |
second = 0; |
// fall thru to 'SECOND' |
case SECOND: |
millis = 0; |
// fall thru to 'MILLISECOND' |
case MILLISECOND: |
break; |
|
case WEEK: |
case DAY_OF_YEAR: |
case DAY_OF_WEEK: |
case TIMEZONE: |
case TIMEZONE_HOUR: |
case TIMEZONE_MINUTE: |
default: |
return false; |
}
|
Attachments
Issue Links
- relates to
-
MB-51392 DATE_TRUNC_STR returns wrong result
- Closed