OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtractFromTime.h File Reference
#include <cstdint>
#include <ctime>
#include "../Shared/funcannotations.h"
+ Include dependency graph for ExtractFromTime.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ExtractField {
  kYEAR, kQUARTER, kMONTH, kDAY,
  kHOUR, kMINUTE, kSECOND, kMILLISECOND,
  kMICROSECOND, kNANOSECOND, kDOW, kISODOW,
  kDOY, kEPOCH, kQUARTERDAY, kWEEK,
  kWEEK_SUNDAY, kWEEK_SATURDAY, kDATEEPOCH, kUNKNOWN_FIELD
}
 

Functions

DEVICE int64_t ExtractFromTime (ExtractField field, const int64_t timeval)
 
DEVICE int64_t floor_div (int64_t const dividend, int64_t const divisor)
 
DEVICE int64_t unsigned_mod (int64_t const dividend, int64_t const divisor)
 

Variables

static constexpr int64_t kNanoSecsPerSec = 1000000000
 
static constexpr int64_t kMicroSecsPerSec = 1000000
 
static constexpr int64_t kMilliSecsPerSec = 1000
 
static constexpr int64_t kMilliSecsPerMin = 60000
 
static constexpr int64_t kMilliSecsPerHour = 3600000
 
static constexpr int64_t kMilliSecsPerDay = 86400000
 
static constexpr int64_t kSecsPerMin = 60
 
static constexpr int64_t kMinsPerHour = 60
 
static constexpr int64_t kHoursPerDay = 24
 
static constexpr int64_t kSecsPerHour = 3600
 
static constexpr int64_t kSecsPerDay = 86400
 
static constexpr int64_t kSecsPerQuarterDay = 21600
 
static constexpr int32_t kDaysPerWeek = 7
 
static constexpr int32_t kMonsPerYear = 12
 
static constexpr int64_t kSecsPerHalfDay = 43200
 
static constexpr int64_t kMinsPerMonth = 43200
 
static constexpr int32_t kYearBase = 1900
 
static constexpr int32_t kEpochAdjustedDays = 11017
 
static constexpr int32_t kEpochAdjustedYears = 2000
 
static constexpr int32_t kEpochAdjustedWDay = 3
 
static constexpr int64_t kDaysPer400Years = 146097
 
static constexpr int64_t kDaysPer100Years = 36524
 
static constexpr int32_t kDaysPer4Years = 3 * 365 + 366
 
static constexpr int32_t kDaysPerYear = 365
 
static constexpr int32_t kDaysInJanuary = 31
 
static constexpr int32_t kDaysInFebruary = 28
 
static constexpr uint32_t kSecondsPerNonLeapYear = 31536000
 
static constexpr uint32_t kSecondsPer4YearCycle = 126230400
 
static constexpr uint32_t kUSecsPerDay = 86400
 
static constexpr uint32_t kEpochOffsetYear1900 = 2208988800
 
static constexpr uint32_t kSecsJanToMar1900 = 5097600
 
constexpr unsigned MARJAN = 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
 
constexpr unsigned JANMAR = 31 + 28
 

Enumeration Type Documentation

Enumerator
kYEAR 
kQUARTER 
kMONTH 
kDAY 
kHOUR 
kMINUTE 
kSECOND 
kMILLISECOND 
kMICROSECOND 
kNANOSECOND 
kDOW 
kISODOW 
kDOY 
kEPOCH 
kQUARTERDAY 
kWEEK 
kWEEK_SUNDAY 
kWEEK_SATURDAY 
kDATEEPOCH 
kUNKNOWN_FIELD 

Definition at line 77 of file ExtractFromTime.h.

Function Documentation

DEVICE int64_t ExtractFromTime ( ExtractField  field,
const int64_t  timeval 
)

Definition at line 294 of file ExtractFromTime.cpp.

References extract_dateepoch(), extract_day(), extract_day_of_year(), extract_dow(), extract_epoch(), extract_hour(), extract_isodow(), extract_microsecond(), extract_millisecond(), extract_minute(), extract_month(), extract_nanosecond(), extract_quarter(), extract_quarterday(), extract_second(), extract_week_monday(), extract_week_saturday(), extract_week_sunday(), extract_year(), kDATEEPOCH, kDAY, kDOW, kDOY, kEPOCH, kHOUR, kISODOW, kMICROSECOND, kMILLISECOND, kMINUTE, kMONTH, kNANOSECOND, kQUARTER, kQUARTERDAY, kSECOND, kUNKNOWN_FIELD, kWEEK, kWEEK_SATURDAY, kWEEK_SUNDAY, and kYEAR.

Referenced by Timestamp::getDay(), getExpressionRange(), DateTimeTranslator::getExtractFromTimeConstantValue(), Timestamp::getHours(), Timestamp::getMicroseconds(), Timestamp::getMilliseconds(), Timestamp::getMinutes(), Timestamp::getMonth(), Timestamp::getNanoseconds(), Timestamp::getSeconds(), and Timestamp::getYear().

294  {
295  switch (field) {
296  case kEPOCH:
297  return extract_epoch(timeval);
298  case kDATEEPOCH:
299  return extract_dateepoch(timeval);
300  case kQUARTERDAY:
301  return extract_quarterday(timeval);
302  case kHOUR:
303  return extract_hour(timeval);
304  case kMINUTE:
305  return extract_minute(timeval);
306  case kSECOND:
307  return extract_second(timeval);
308  case kMILLISECOND:
309  return extract_millisecond(timeval);
310  case kMICROSECOND:
311  return extract_microsecond(timeval);
312  case kNANOSECOND:
313  return extract_nanosecond(timeval);
314  case kDOW:
315  return extract_dow(timeval);
316  case kISODOW:
317  return extract_isodow(timeval);
318  case kDAY:
319  return extract_day(timeval);
320  case kWEEK:
321  return extract_week_monday(timeval);
322  case kWEEK_SUNDAY:
323  return extract_week_sunday(timeval);
324  case kWEEK_SATURDAY:
325  return extract_week_saturday(timeval);
326  case kDOY:
327  return extract_day_of_year(timeval);
328  case kMONTH:
329  return extract_month(timeval);
330  case kQUARTER:
331  return extract_quarter(timeval);
332  case kYEAR:
333  return extract_year(timeval);
334  case kUNKNOWN_FIELD:
335  return -1;
336  }
337 
338 #ifdef __CUDACC__
339  return -1;
340 #else
341  abort();
342 #endif
343 }
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_year(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_second(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_minute(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_month(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_nanosecond(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_millisecond(const int64_t lcltime)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_sunday(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_hour(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_quarter(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_monday(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_dateepoch(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_day(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_epoch(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_dow(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_saturday(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_isodow(const int64_t timeval)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_microsecond(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_quarterday(const int64_t lcltime)
RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_day_of_year(const int64_t timeval)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE int64_t floor_div ( int64_t const  dividend,
int64_t const  divisor 
)
inline
DEVICE int64_t unsigned_mod ( int64_t const  dividend,
int64_t const  divisor 
)
inline

Variable Documentation

constexpr unsigned JANMAR = 31 + 28
constexpr int32_t kDaysInFebruary = 28
static

Definition at line 65 of file ExtractFromTime.h.

constexpr int32_t kDaysInJanuary = 31
static

Definition at line 63 of file ExtractFromTime.h.

constexpr int64_t kDaysPer100Years = 36524
static

Definition at line 57 of file ExtractFromTime.h.

constexpr int32_t kDaysPer4Years = 3 * 365 + 366
static

Definition at line 59 of file ExtractFromTime.h.

constexpr int32_t kDaysPerWeek = 7
static

Definition at line 37 of file ExtractFromTime.h.

Referenced by extract_dow(), and extract_isodow().

constexpr int32_t kDaysPerYear = 365
static

Definition at line 61 of file ExtractFromTime.h.

constexpr int32_t kEpochAdjustedWDay = 3
static

Definition at line 53 of file ExtractFromTime.h.

constexpr int32_t kEpochAdjustedYears = 2000
static

Definition at line 51 of file ExtractFromTime.h.

constexpr uint32_t kEpochOffsetYear1900 = 2208988800
static
constexpr int64_t kHoursPerDay = 24
static

Definition at line 33 of file ExtractFromTime.h.

constexpr int64_t kMilliSecsPerDay = 86400000
static
constexpr int64_t kMinsPerHour = 60
static

Definition at line 32 of file ExtractFromTime.h.

constexpr int64_t kMinsPerMonth = 43200
static

Definition at line 40 of file ExtractFromTime.h.

constexpr int32_t kMonsPerYear = 12
static

Definition at line 38 of file ExtractFromTime.h.

Referenced by datetrunc_month(), and extract_month_fast().

constexpr uint32_t kSecondsPer4YearCycle = 126230400
static
constexpr uint32_t kSecondsPerNonLeapYear = 31536000
static
constexpr uint32_t kSecsJanToMar1900 = 5097600
static
constexpr int64_t kSecsPerHalfDay = 43200
static

Definition at line 39 of file ExtractFromTime.h.

constexpr int64_t kSecsPerQuarterDay = 21600
static

Definition at line 36 of file ExtractFromTime.h.

Referenced by datetrunc_quarterday(), and extract_quarterday().

constexpr uint32_t kUSecsPerDay = 86400
static
constexpr int32_t kYearBase = 1900
static

Definition at line 42 of file ExtractFromTime.h.

constexpr unsigned MARJAN = 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31