OmniSciDB  2e3a973ef4
com.mapd.tests.DateTimeTest.DateExtractUnit Enum Reference
+ Collaboration diagram for com.mapd.tests.DateTimeTest.DateExtractUnit:

Public Attributes

 daYEAR
 
 daQUARTER
 
 daMONTH
 
 daDAY
 
 daHOUR
 
 daMINUTE
 
 daSECOND
 
 daMILLISECOND
 
 daMICROSECOND
 
 daNANOSECOND
 
 daWEEK
 
 daDAYOFYEAR
 

Private Member Functions

 DateExtractUnit (String token, Function< LocalDateTime, Long > f)
 

Private Attributes

String sqlToken
 
Function< LocalDateTime, Long > extract
 

Detailed Description

Definition at line 203 of file DateTimeTest.java.

Constructor & Destructor Documentation

◆ DateExtractUnit()

com.mapd.tests.DateTimeTest.DateExtractUnit.DateExtractUnit ( String  token,
Function< LocalDateTime, Long >  f 
)
inlineprivate

Definition at line 334 of file DateTimeTest.java.

334  {
335  this.sqlToken = token;
336  this.extract = f;
337  }
Function< LocalDateTime, Long > extract

Member Data Documentation

◆ daDAY

com.mapd.tests.DateTimeTest.DateExtractUnit.daDAY
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.DAY_OF_MONTH);
}
})

Definition at line 240 of file DateTimeTest.java.

◆ daDAYOFYEAR

com.mapd.tests.DateTimeTest.DateExtractUnit.daDAYOFYEAR
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.DAY_OF_YEAR);
}
})

Definition at line 324 of file DateTimeTest.java.

◆ daHOUR

com.mapd.tests.DateTimeTest.DateExtractUnit.daHOUR
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.HOUR_OF_DAY);
}
})

Definition at line 246 of file DateTimeTest.java.

◆ daMICROSECOND

com.mapd.tests.DateTimeTest.DateExtractUnit.daMICROSECOND
Initial value:
=("MICROSECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.MICRO_OF_SECOND)
+ (1000_000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 274 of file DateTimeTest.java.

◆ daMILLISECOND

com.mapd.tests.DateTimeTest.DateExtractUnit.daMILLISECOND
Initial value:
=("MILLISECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.MILLI_OF_SECOND)
+ (1000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 267 of file DateTimeTest.java.

◆ daMINUTE

com.mapd.tests.DateTimeTest.DateExtractUnit.daMINUTE
Initial value:
=("MINUTE", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.MINUTE_OF_HOUR);
}
})

Definition at line 252 of file DateTimeTest.java.

◆ daMONTH

com.mapd.tests.DateTimeTest.DateExtractUnit.daMONTH
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.MONTH_OF_YEAR);
}
})

Definition at line 234 of file DateTimeTest.java.

◆ daNANOSECOND

com.mapd.tests.DateTimeTest.DateExtractUnit.daNANOSECOND
Initial value:
=("NANOSECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.NANO_OF_SECOND)
+ (1000_000_000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 281 of file DateTimeTest.java.

◆ daQUARTER

com.mapd.tests.DateTimeTest.DateExtractUnit.daQUARTER
Initial value:
=("QUARTER", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
int month = t.get(ChronoField.MONTH_OF_YEAR);
switch (month) {
case 1:
case 2:
case 3:
return 1l;
case 4:
case 5:
case 6:
return 2l;
case 7:
case 8:
case 9:
return 3l;
case 10:
case 11:
case 12:
return 4l;
}
return -1l;
}
})

Definition at line 209 of file DateTimeTest.java.

◆ daSECOND

com.mapd.tests.DateTimeTest.DateExtractUnit.daSECOND
Initial value:
=("SECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.SECOND_OF_MINUTE);
}
})

Definition at line 258 of file DateTimeTest.java.

◆ daWEEK

com.mapd.tests.DateTimeTest.DateExtractUnit.daWEEK
Initial value:
@Override
public Long apply(LocalDateTime t) {
LocalDateTime year = DateTruncUnit.dtYEAR.trunc.apply(t);
year = year.plusDays(3);
LocalDateTime week = DateTruncUnit.dtWEEK.trunc.apply(year);
if (week.compareTo(t) > 0) {
year = year.minusYears(1);
week = DateTruncUnit.dtWEEK.trunc.apply(year);
}
int weeks = 0;
while (week.compareTo(t) <= 0) {
weeks++;
week = week.plusWeeks(1);
}
return (long) weeks;
}
})

Definition at line 288 of file DateTimeTest.java.

◆ daYEAR

com.mapd.tests.DateTimeTest.DateExtractUnit.daYEAR
Initial value:
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.YEAR);
}
})

Definition at line 204 of file DateTimeTest.java.

◆ extract

Function<LocalDateTime, Long> com.mapd.tests.DateTimeTest.DateExtractUnit.extract
private

Definition at line 332 of file DateTimeTest.java.

◆ sqlToken

String com.mapd.tests.DateTimeTest.DateExtractUnit.sqlToken
private

Definition at line 331 of file DateTimeTest.java.


The documentation for this enum was generated from the following file: