OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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
}
 

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 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 

Definition at line 73 of file ExtractFromTime.h.

Function Documentation

DEVICE int64_t ExtractFromTime ( ExtractField  field,
const int64_t  timeval 
)

Definition at line 248 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, kWEEK, kWEEK_SATURDAY, kWEEK_SUNDAY, and kYEAR.

Referenced by getExpressionRange(), and DateTimeTranslator::getExtractFromTimeConstantValue().

248  {
249  switch (field) {
250  case kEPOCH:
251  return extract_epoch(timeval);
252  case kDATEEPOCH:
253  return extract_dateepoch(timeval);
254  case kQUARTERDAY:
255  return extract_quarterday(timeval);
256  case kHOUR:
257  return extract_hour(timeval);
258  case kMINUTE:
259  return extract_minute(timeval);
260  case kSECOND:
261  return extract_second(timeval);
262  case kMILLISECOND:
263  return extract_millisecond(timeval);
264  case kMICROSECOND:
265  return extract_microsecond(timeval);
266  case kNANOSECOND:
267  return extract_nanosecond(timeval);
268  case kDOW:
269  return extract_dow(timeval);
270  case kISODOW:
271  return extract_isodow(timeval);
272  case kDAY:
273  return extract_day(timeval);
274  case kWEEK:
275  return extract_week_monday(timeval);
276  case kWEEK_SUNDAY:
277  return extract_week_sunday(timeval);
278  case kWEEK_SATURDAY:
279  return extract_week_saturday(timeval);
280  case kDOY:
281  return extract_day_of_year(timeval);
282  case kMONTH:
283  return extract_month(timeval);
284  case kQUARTER:
285  return extract_quarter(timeval);
286  case kYEAR:
287  return extract_year(timeval);
288  }
289 
290 #ifdef __CUDACC__
291  return -1;
292 #else
293  abort();
294 #endif
295 }
ALWAYS_INLINE DEVICE int64_t extract_second(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_nanosecond(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_month(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_isodow(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_day_of_year(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_minute(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_quarterday(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_week_sunday(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_quarter(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_dow(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_week_monday(const int64_t timeval)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
ALWAYS_INLINE DEVICE int64_t extract_dateepoch(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_year(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_week_saturday(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_microsecond(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_hour(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_epoch(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_millisecond(const int64_t lcltime)
ALWAYS_INLINE DEVICE int64_t extract_day(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

Definition at line 105 of file ExtractFromTime.h.

Referenced by datetrunc_century(), datetrunc_day(), datetrunc_decade(), datetrunc_hour(), datetrunc_millennium(), datetrunc_minute(), datetrunc_month(), datetrunc_quarter(), datetrunc_quarterday(), datetrunc_week(), datetrunc_year(), extract_dateepoch(), extract_day(), extract_day_of_year(), extract_dow(), extract_hour(), extract_isodow(), extract_microsecond(), extract_millisecond(), extract_minute(), extract_month(), extract_nanosecond(), extract_quarter(), extract_quarterday(), extract_second(), extract_week(), and DateTimeTranslator::getDateTruncConstantValue().

105  {
106  int64_t mod = dividend % divisor;
107  if (mod < 0) {
108  mod += divisor;
109  }
110  return mod;
111 }

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 61 of file ExtractFromTime.h.

constexpr int32_t kDaysInJanuary = 31
static

Definition at line 59 of file ExtractFromTime.h.

constexpr int64_t kDaysPer100Years = 36524
static

Definition at line 53 of file ExtractFromTime.h.

constexpr int32_t kDaysPer4Years = 3 * 365 + 366
static

Definition at line 55 of file ExtractFromTime.h.

constexpr int32_t kDaysPerWeek = 7
static

Definition at line 33 of file ExtractFromTime.h.

Referenced by extract_dow(), and extract_isodow().

constexpr int32_t kDaysPerYear = 365
static

Definition at line 57 of file ExtractFromTime.h.

constexpr int32_t kEpochAdjustedWDay = 3
static

Definition at line 49 of file ExtractFromTime.h.

constexpr int32_t kEpochAdjustedYears = 2000
static

Definition at line 47 of file ExtractFromTime.h.

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

Definition at line 29 of file ExtractFromTime.h.

constexpr int64_t kMinsPerHour = 60
static

Definition at line 28 of file ExtractFromTime.h.

constexpr int64_t kMinsPerMonth = 43200
static

Definition at line 36 of file ExtractFromTime.h.

constexpr int32_t kMonsPerYear = 12
static

Definition at line 34 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 35 of file ExtractFromTime.h.

constexpr int64_t kSecsPerHour = 3600
static

Definition at line 30 of file ExtractFromTime.h.

Referenced by DateDiff(), datetrunc_hour(), extract_hour(), and extract_minute().

constexpr int64_t kSecsPerMin = 60
static
constexpr int64_t kSecsPerQuarterDay = 21600
static

Definition at line 32 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 38 of file ExtractFromTime.h.

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