OmniSciDB  8a228a1076
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,
  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

◆ ExtractField

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

Definition at line 73 of file ExtractFromTime.h.

Function Documentation

◆ ExtractFromTime()

DEVICE int64_t ExtractFromTime ( ExtractField  field,
const int64_t  timeval 
)

Definition at line 228 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(), extract_year(), kDATEEPOCH, kDAY, kDOW, kDOY, kEPOCH, kHOUR, kISODOW, kMICROSECOND, kMILLISECOND, kMINUTE, kMONTH, kNANOSECOND, kQUARTER, kQUARTERDAY, kSECOND, kWEEK, and kYEAR.

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

228  {
229  switch (field) {
230  case kEPOCH:
231  return extract_epoch(timeval);
232  case kDATEEPOCH:
233  return extract_dateepoch(timeval);
234  case kQUARTERDAY:
235  return extract_quarterday(timeval);
236  case kHOUR:
237  return extract_hour(timeval);
238  case kMINUTE:
239  return extract_minute(timeval);
240  case kSECOND:
241  return extract_second(timeval);
242  case kMILLISECOND:
243  return extract_millisecond(timeval);
244  case kMICROSECOND:
245  return extract_microsecond(timeval);
246  case kNANOSECOND:
247  return extract_nanosecond(timeval);
248  case kDOW:
249  return extract_dow(timeval);
250  case kISODOW:
251  return extract_isodow(timeval);
252  case kDAY:
253  return extract_day(timeval);
254  case kWEEK:
255  return extract_week(timeval);
256  case kDOY:
257  return extract_day_of_year(timeval);
258  case kMONTH:
259  return extract_month(timeval);
260  case kQUARTER:
261  return extract_quarter(timeval);
262  case kYEAR:
263  return extract_year(timeval);
264  }
265 
266 #ifdef __CUDACC__
267  return -1;
268 #else
269  abort();
270 #endif
271 }
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_quarter(const int64_t timeval)
ALWAYS_INLINE DEVICE int64_t extract_dow(const int64_t lcltime)
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_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)
ALWAYS_INLINE DEVICE int64_t extract_week(const int64_t timeval)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ floor_div()

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

◆ unsigned_mod()

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

Definition at line 103 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().

103  {
104  int64_t mod = dividend % divisor;
105  if (mod < 0) {
106  mod += divisor;
107  }
108  return mod;
109 }
+ Here is the caller graph for this function:

Variable Documentation

◆ JANMAR

constexpr unsigned JANMAR = 31 + 28

◆ kDaysInFebruary

constexpr int32_t kDaysInFebruary = 28
static

Definition at line 61 of file ExtractFromTime.h.

◆ kDaysInJanuary

constexpr int32_t kDaysInJanuary = 31
static

Definition at line 59 of file ExtractFromTime.h.

◆ kDaysPer100Years

constexpr int64_t kDaysPer100Years = 36524
static

Definition at line 53 of file ExtractFromTime.h.

◆ kDaysPer400Years

◆ kDaysPer4Years

constexpr int32_t kDaysPer4Years = 3 * 365 + 366
static

Definition at line 55 of file ExtractFromTime.h.

◆ kDaysPerWeek

constexpr int32_t kDaysPerWeek = 7
static

Definition at line 33 of file ExtractFromTime.h.

Referenced by extract_dow(), and extract_isodow().

◆ kDaysPerYear

constexpr int32_t kDaysPerYear = 365
static

Definition at line 57 of file ExtractFromTime.h.

◆ kEpochAdjustedDays

◆ kEpochAdjustedWDay

constexpr int32_t kEpochAdjustedWDay = 3
static

Definition at line 49 of file ExtractFromTime.h.

◆ kEpochAdjustedYears

constexpr int32_t kEpochAdjustedYears = 2000
static

Definition at line 47 of file ExtractFromTime.h.

◆ kEpochOffsetYear1900

constexpr uint32_t kEpochOffsetYear1900 = 2208988800
static

◆ kHoursPerDay

constexpr int64_t kHoursPerDay = 24
static

Definition at line 29 of file ExtractFromTime.h.

◆ kMicroSecsPerSec

◆ kMilliSecsPerSec

◆ kMinsPerHour

constexpr int64_t kMinsPerHour = 60
static

Definition at line 28 of file ExtractFromTime.h.

◆ kMinsPerMonth

constexpr int64_t kMinsPerMonth = 43200
static

Definition at line 36 of file ExtractFromTime.h.

◆ kMonsPerYear

constexpr int32_t kMonsPerYear = 12
static

Definition at line 34 of file ExtractFromTime.h.

Referenced by datetrunc_month(), and extract_month_fast().

◆ kNanoSecsPerSec

◆ kSecondsPer4YearCycle

constexpr uint32_t kSecondsPer4YearCycle = 126230400
static

◆ kSecondsPerNonLeapYear

constexpr uint32_t kSecondsPerNonLeapYear = 31536000
static

◆ kSecsJanToMar1900

constexpr uint32_t kSecsJanToMar1900 = 5097600
static

◆ kSecsPerDay

◆ kSecsPerHalfDay

constexpr int64_t kSecsPerHalfDay = 43200
static

Definition at line 35 of file ExtractFromTime.h.

Referenced by TimeGM::parse_meridians().

◆ kSecsPerHour

constexpr int64_t kSecsPerHour = 3600
static

Definition at line 30 of file ExtractFromTime.h.

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

◆ kSecsPerMin

constexpr int64_t kSecsPerMin = 60
static

◆ kSecsPerQuarterDay

constexpr int64_t kSecsPerQuarterDay = 21600
static

Definition at line 32 of file ExtractFromTime.h.

Referenced by datetrunc_quarterday(), and extract_quarterday().

◆ kUSecsPerDay

constexpr uint32_t kUSecsPerDay = 86400
static

◆ kYearBase

constexpr int32_t kYearBase = 1900
static

Definition at line 38 of file ExtractFromTime.h.

◆ MARJAN

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