OmniSciDB  0264ff685a
ExtractFromTime.cpp File Reference
#include "ExtractFromTime.h"
#include <cstdlib>
+ Include dependency graph for ExtractFromTime.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{ExtractFromTime.cpp}
 

Functions

template<unsigned OFFSET>
DEVICE unsigned anonymous_namespace{ExtractFromTime.cpp}::week_start_from_yoe (unsigned const yoe)
 
ALWAYS_INLINE DEVICE int64_t extract_hour (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_minute (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_second (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_millisecond (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_microsecond (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_nanosecond (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_dow (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_quarterday (const int64_t lcltime)
 
DEVICE int32_t extract_month_fast (const int64_t lcltime)
 
DEVICE int32_t extract_quarter_fast (const int64_t lcltime)
 
DEVICE int32_t extract_year_fast (const int64_t lcltime)
 
ALWAYS_INLINE DEVICE int64_t extract_epoch (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_dateepoch (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_isodow (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_day (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_day_of_year (const int64_t timeval)
 
template<unsigned OFFSET>
ALWAYS_INLINE DEVICE int64_t extract_week (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_week_monday (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_week_sunday (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_week_saturday (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_month (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_quarter (const int64_t timeval)
 
ALWAYS_INLINE DEVICE int64_t extract_year (const int64_t timeval)
 
DEVICE int64_t ExtractFromTime (ExtractField field, const int64_t timeval)
 

Variables

constexpr unsigned anonymous_namespace{ExtractFromTime.cpp}::MONDAY = 2
 
constexpr unsigned anonymous_namespace{ExtractFromTime.cpp}::SUNDAY = 3
 
constexpr unsigned anonymous_namespace{ExtractFromTime.cpp}::SATURDAY = 4
 

Function Documentation

◆ extract_dateepoch()

ALWAYS_INLINE DEVICE int64_t extract_dateepoch ( const int64_t  timeval)

Definition at line 151 of file ExtractFromTime.cpp.

References kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

151  {
152  return timeval - unsigned_mod(timeval, kSecsPerDay);
153 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_day()

ALWAYS_INLINE DEVICE int64_t extract_day ( const int64_t  timeval)

Definition at line 161 of file ExtractFromTime.cpp.

References floor_div(), kDaysPer400Years, kEpochAdjustedDays, kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

161  {
162  int64_t const day = floor_div(timeval, kSecsPerDay);
163  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
164  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
165  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
166  unsigned const moy = (5 * doy + 2) / 153;
167  return doy - (153 * moy + 2) / 5 + 1;
168 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_day_of_year()

ALWAYS_INLINE DEVICE int64_t extract_day_of_year ( const int64_t  timeval)

Definition at line 170 of file ExtractFromTime.cpp.

References floor_div(), JANMAR, kDaysPer400Years, kEpochAdjustedDays, kSecsPerDay, MARJAN, and unsigned_mod().

Referenced by ExtractFromTime().

170  {
171  int64_t const day = floor_div(timeval, kSecsPerDay);
172  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
173  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
174  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
175  return doy + (doy < MARJAN ? 1 + JANMAR + (yoe % 4 == 0 && (yoe % 100 != 0 || yoe == 0))
176  : 1 - MARJAN);
177 }
static constexpr int64_t kSecsPerDay
constexpr unsigned JANMAR
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
constexpr unsigned MARJAN
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_dow()

ALWAYS_INLINE DEVICE int64_t extract_dow ( const int64_t  lcltime)

Definition at line 73 of file ExtractFromTime.cpp.

References floor_div(), kDaysPerWeek, kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

73  {
74  int64_t const days_past_epoch = floor_div(lcltime, kSecsPerDay);
75  return unsigned_mod(days_past_epoch + 4, kDaysPerWeek);
76 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr int32_t kDaysPerWeek
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_epoch()

ALWAYS_INLINE DEVICE int64_t extract_epoch ( const int64_t  timeval)

Definition at line 147 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

147  {
148  return timeval;
149 }
+ Here is the caller graph for this function:

◆ extract_hour()

ALWAYS_INLINE DEVICE int64_t extract_hour ( const int64_t  lcltime)

Definition at line 48 of file ExtractFromTime.cpp.

References kSecsPerDay, kSecsPerHour, and unsigned_mod().

Referenced by ExtractFromTime().

48  {
49  return unsigned_mod(lcltime, kSecsPerDay) / kSecsPerHour;
50 }
static constexpr int64_t kSecsPerDay
static constexpr int64_t kSecsPerHour
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_isodow()

ALWAYS_INLINE DEVICE int64_t extract_isodow ( const int64_t  timeval)

Definition at line 156 of file ExtractFromTime.cpp.

References floor_div(), kDaysPerWeek, kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

156  {
157  int64_t const days_past_epoch = floor_div(timeval, kSecsPerDay);
158  return unsigned_mod(days_past_epoch + 3, kDaysPerWeek) + 1;
159 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr int32_t kDaysPerWeek
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_microsecond()

ALWAYS_INLINE DEVICE int64_t extract_microsecond ( const int64_t  lcltime)

Definition at line 64 of file ExtractFromTime.cpp.

References kMicroSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

64  {
65  return unsigned_mod(lcltime, kSecsPerMin * kMicroSecsPerSec);
66 }
static constexpr int64_t kSecsPerMin
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
static constexpr int64_t kMicroSecsPerSec
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_millisecond()

ALWAYS_INLINE DEVICE int64_t extract_millisecond ( const int64_t  lcltime)

Definition at line 60 of file ExtractFromTime.cpp.

References kMilliSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

60  {
61  return unsigned_mod(lcltime, kSecsPerMin * kMilliSecsPerSec);
62 }
static constexpr int64_t kSecsPerMin
static constexpr int64_t kMilliSecsPerSec
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_minute()

ALWAYS_INLINE DEVICE int64_t extract_minute ( const int64_t  lcltime)

Definition at line 52 of file ExtractFromTime.cpp.

References kSecsPerHour, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

52  {
53  return unsigned_mod(lcltime, kSecsPerHour) / kSecsPerMin;
54 }
static constexpr int64_t kSecsPerHour
static constexpr int64_t kSecsPerMin
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_month()

ALWAYS_INLINE DEVICE int64_t extract_month ( const int64_t  timeval)

Definition at line 208 of file ExtractFromTime.cpp.

References extract_month_fast(), floor_div(), kDaysPer400Years, kEpochAdjustedDays, kEpochOffsetYear1900, kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

208  {
209  if (timeval >= 0L && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
210  return extract_month_fast(timeval);
211  }
212  int64_t const day = floor_div(timeval, kSecsPerDay);
213  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
214  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
215  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
216  unsigned const moy = (5 * doy + 2) / 153;
217  return moy + (moy < 10 ? 3 : -9);
218 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr uint32_t kEpochOffsetYear1900
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
DEVICE int32_t extract_month_fast(const int64_t lcltime)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_month_fast()

DEVICE int32_t extract_month_fast ( const int64_t  lcltime)

Definition at line 82 of file ExtractFromTime.cpp.

References kEpochOffsetYear1900, kMonsPerYear, kSecondsPer4YearCycle, kSecondsPerNonLeapYear, kSecsJanToMar1900, kUSecsPerDay, and STATIC_QUAL.

Referenced by extract_month().

82  {
83  STATIC_QUAL const uint32_t cumulative_month_epoch_starts[kMonsPerYear] = {0,
84  2678400,
85  5270400,
86  7948800,
87  10540800,
88  13219200,
89  15897600,
90  18489600,
91  21168000,
92  23760000,
93  26438400,
94  29116800};
95  uint32_t seconds_march_1900 = lcltime + kEpochOffsetYear1900 - kSecsJanToMar1900;
96  uint32_t seconds_past_4year_period = seconds_march_1900 % kSecondsPer4YearCycle;
97  uint32_t year_seconds_past_4year_period =
98  (seconds_past_4year_period / kSecondsPerNonLeapYear) * kSecondsPerNonLeapYear;
99  if (seconds_past_4year_period >=
100  kSecondsPer4YearCycle - kUSecsPerDay) { // if we are in Feb 29th
101  year_seconds_past_4year_period -= kSecondsPerNonLeapYear;
102  }
103  uint32_t seconds_past_march =
104  seconds_past_4year_period - year_seconds_past_4year_period;
105  uint32_t month =
106  seconds_past_march / (30 * kUSecsPerDay); // Will make the correct month either be
107  // the guessed month or month before
108  month = month <= 11 ? month : 11;
109  if (cumulative_month_epoch_starts[month] > seconds_past_march) {
110  month--;
111  }
112  return (month + 2) % 12 + 1;
113 }
static constexpr uint32_t kSecsJanToMar1900
static constexpr uint32_t kUSecsPerDay
#define STATIC_QUAL
static constexpr uint32_t kEpochOffsetYear1900
static constexpr uint32_t kSecondsPer4YearCycle
static constexpr uint32_t kSecondsPerNonLeapYear
static constexpr int32_t kMonsPerYear
+ Here is the caller graph for this function:

◆ extract_nanosecond()

ALWAYS_INLINE DEVICE int64_t extract_nanosecond ( const int64_t  lcltime)

Definition at line 68 of file ExtractFromTime.cpp.

References kNanoSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

68  {
69  return unsigned_mod(lcltime, kSecsPerMin * kNanoSecsPerSec);
70 }
static constexpr int64_t kSecsPerMin
static constexpr int64_t kNanoSecsPerSec
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_quarter()

ALWAYS_INLINE DEVICE int64_t extract_quarter ( const int64_t  timeval)

Definition at line 220 of file ExtractFromTime.cpp.

References extract_quarter_fast(), floor_div(), kDaysPer400Years, kEpochAdjustedDays, kEpochOffsetYear1900, kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

220  {
221  if (timeval >= 0L && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
222  return extract_quarter_fast(timeval);
223  }
224  constexpr int64_t quarter[12]{1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 1, 1};
225  int64_t const day = floor_div(timeval, kSecsPerDay);
226  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
227  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
228  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
229  unsigned const moy = (5 * doy + 2) / 153;
230  return quarter[moy];
231 }
static constexpr int64_t kSecsPerDay
DEVICE int32_t extract_quarter_fast(const int64_t lcltime)
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr uint32_t kEpochOffsetYear1900
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_quarter_fast()

DEVICE int32_t extract_quarter_fast ( const int64_t  lcltime)

Definition at line 115 of file ExtractFromTime.cpp.

References kEpochOffsetYear1900, kSecondsPer4YearCycle, kSecondsPerNonLeapYear, kSecsJanToMar1900, kSecsPerDay, kUSecsPerDay, and STATIC_QUAL.

Referenced by extract_quarter().

115  {
116  STATIC_QUAL const uint32_t cumulative_quarter_epoch_starts[4] = {
117  0, 7776000, 15638400, 23587200};
118  STATIC_QUAL const uint32_t cumulative_quarter_epoch_starts_leap_year[4] = {
119  0, 7862400, 15724800, 23673600};
120  uint32_t seconds_1900 = lcltime + kEpochOffsetYear1900;
121  uint32_t leap_years = (seconds_1900 - kSecsJanToMar1900) / kSecondsPer4YearCycle;
122  uint32_t year = (seconds_1900 - leap_years * kSecsPerDay) / kSecondsPerNonLeapYear;
123  uint32_t base_year_leap_years = (year - 1) / 4;
124  uint32_t base_year_seconds =
125  year * kSecondsPerNonLeapYear + base_year_leap_years * kUSecsPerDay;
126  bool is_leap_year = year % 4 == 0 && year != 0;
127  const uint32_t* quarter_offsets = is_leap_year
128  ? cumulative_quarter_epoch_starts_leap_year
129  : cumulative_quarter_epoch_starts;
130  uint32_t partial_year_seconds = seconds_1900 % base_year_seconds;
131  uint32_t quarter = partial_year_seconds / (90 * kUSecsPerDay);
132  quarter = quarter <= 3 ? quarter : 3;
133  if (quarter_offsets[quarter] > partial_year_seconds) {
134  quarter--;
135  }
136  return quarter + 1;
137 }
static constexpr int64_t kSecsPerDay
static constexpr uint32_t kSecsJanToMar1900
static constexpr uint32_t kUSecsPerDay
#define STATIC_QUAL
static constexpr uint32_t kEpochOffsetYear1900
static constexpr uint32_t kSecondsPer4YearCycle
static constexpr uint32_t kSecondsPerNonLeapYear
+ Here is the caller graph for this function:

◆ extract_quarterday()

ALWAYS_INLINE DEVICE int64_t extract_quarterday ( const int64_t  lcltime)

Definition at line 78 of file ExtractFromTime.cpp.

References kSecsPerDay, kSecsPerQuarterDay, and unsigned_mod().

Referenced by ExtractFromTime().

78  {
79  return unsigned_mod(lcltime, kSecsPerDay) / kSecsPerQuarterDay + 1;
80 }
static constexpr int64_t kSecsPerDay
static constexpr int64_t kSecsPerQuarterDay
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_second()

ALWAYS_INLINE DEVICE int64_t extract_second ( const int64_t  lcltime)

Definition at line 56 of file ExtractFromTime.cpp.

References kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

56  {
57  return unsigned_mod(lcltime, kSecsPerMin);
58 }
static constexpr int64_t kSecsPerMin
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_week()

template<unsigned OFFSET>
ALWAYS_INLINE DEVICE int64_t extract_week ( const int64_t  timeval)

Definition at line 180 of file ExtractFromTime.cpp.

References floor_div(), kDaysPer400Years, kEpochAdjustedDays, kSecsPerDay, and unsigned_mod().

180  {
181  int64_t const day = floor_div(timeval, kSecsPerDay);
182  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
183  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
184  unsigned week_start = week_start_from_yoe<OFFSET>(yoe);
185  if (doe < week_start) {
186  if (yoe == 0) {
187  // 2000-03-01 is OFFSET days from start of week, week + 9.
188  return (doe + OFFSET) / 7 + 9;
189  } else {
190  week_start = week_start_from_yoe<OFFSET>(yoe - 1);
191  }
192  }
193  return (doe - week_start) / 7 + 1;
194 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
DEVICE int64_t unsigned_mod(int64_t const dividend, int64_t const divisor)
+ Here is the call graph for this function:

◆ extract_week_monday()

ALWAYS_INLINE DEVICE int64_t extract_week_monday ( const int64_t  timeval)

Definition at line 196 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

196  {
197  return extract_week<MONDAY>(timeval);
198 }
+ Here is the caller graph for this function:

◆ extract_week_saturday()

ALWAYS_INLINE DEVICE int64_t extract_week_saturday ( const int64_t  timeval)

Definition at line 204 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

204  {
205  return extract_week<SATURDAY>(timeval);
206 }
+ Here is the caller graph for this function:

◆ extract_week_sunday()

ALWAYS_INLINE DEVICE int64_t extract_week_sunday ( const int64_t  timeval)

Definition at line 200 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

200  {
201  return extract_week<SUNDAY>(timeval);
202 }
+ Here is the caller graph for this function:

◆ extract_year()

ALWAYS_INLINE DEVICE int64_t extract_year ( const int64_t  timeval)

Definition at line 233 of file ExtractFromTime.cpp.

References extract_year_fast(), floor_div(), kDaysPer400Years, kEpochAdjustedDays, kEpochOffsetYear1900, kSecsPerDay, and MARJAN.

Referenced by ExtractFromTime().

233  {
234  if (timeval >= 0L && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
235  return extract_year_fast(timeval);
236  }
237  int64_t const day = floor_div(timeval, kSecsPerDay);
238  int64_t const era = floor_div(day - kEpochAdjustedDays, kDaysPer400Years);
239  unsigned const doe = day - kEpochAdjustedDays - era * kDaysPer400Years;
240  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
241  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
242  return 2000 + era * 400 + yoe + (MARJAN <= doy);
243 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
static constexpr uint32_t kEpochOffsetYear1900
static constexpr int32_t kEpochAdjustedDays
static constexpr int64_t kDaysPer400Years
constexpr unsigned MARJAN
DEVICE int32_t extract_year_fast(const int64_t lcltime)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_year_fast()

DEVICE int32_t extract_year_fast ( const int64_t  lcltime)

Definition at line 139 of file ExtractFromTime.cpp.

References kEpochOffsetYear1900, kSecondsPer4YearCycle, kSecondsPerNonLeapYear, kSecsJanToMar1900, and kUSecsPerDay.

Referenced by extract_year().

139  {
140  const uint32_t seconds_1900 = lcltime + kEpochOffsetYear1900;
141  const uint32_t leap_years = (seconds_1900 - kSecsJanToMar1900) / kSecondsPer4YearCycle;
142  const uint32_t year =
143  (seconds_1900 - leap_years * kUSecsPerDay) / kSecondsPerNonLeapYear + 1900;
144  return year;
145 }
static constexpr uint32_t kSecsJanToMar1900
static constexpr uint32_t kUSecsPerDay
static constexpr uint32_t kEpochOffsetYear1900
static constexpr uint32_t kSecondsPer4YearCycle
static constexpr uint32_t kSecondsPerNonLeapYear
+ Here is the caller graph for this function:

◆ ExtractFromTime()

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: