OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtractFromTime.cpp File Reference
#include "ExtractFromTime.h"
#include <cstdlib>
+ Include dependency graph for ExtractFromTime.cpp:
+ This graph shows which files directly or indirectly include this file:

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)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_hour (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_second (const int64_t lcltime)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_millisecond (const int64_t lcltime)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_microsecond (const int64_t lcltime)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_nanosecond (const int64_t lcltime)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_dow (const int64_t lcltime)
 
RUNTIME_EXPORT 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)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_epoch (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_isodow (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_day_of_year (const int64_t timeval)
 
template<unsigned OFFSET>
ALWAYS_INLINE DEVICE int64_t extract_week (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_week_sunday (const int64_t timeval)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_week_saturday (const int64_t timeval)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_month (const int64_t timeval)
 
RUNTIME_EXPORT ALWAYS_INLINE
DEVICE int64_t 
extract_quarter (const int64_t timeval)
 
RUNTIME_EXPORT 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

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_dateepoch ( const int64_t  timeval)

Definition at line 161 of file ExtractFromTime.cpp.

References kSecsPerDay, and unsigned_mod().

Referenced by ExtractFromTime().

161  {
162  return timeval - unsigned_mod(timeval, kSecsPerDay);
163 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_day ( const int64_t  timeval)

Definition at line 173 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

173  {
174  int64_t const day = floor_div(timeval, kSecsPerDay);
175  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
176  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
177  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
178  unsigned const moy = (5 * doy + 2) / 153;
179  return doy - (153 * moy + 2) / 5 + 1;
180 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_day_of_year ( const int64_t  timeval)

Definition at line 183 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

183  {
184  int64_t const day = floor_div(timeval, kSecsPerDay);
185  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
186  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
187  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
188  return doy + (doy < MARJAN ? 1 + JANMAR + (yoe % 4 == 0 && (yoe % 100 != 0 || yoe == 0))
189  : 1 - MARJAN);
190 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_dow ( const int64_t  lcltime)

Definition at line 80 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

80  {
81  int64_t const days_past_epoch = floor_div(lcltime, kSecsPerDay);
82  return unsigned_mod(days_past_epoch + 4, kDaysPerWeek);
83 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_epoch ( const int64_t  timeval)

Definition at line 156 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

156  {
157  return timeval;
158 }

+ Here is the caller graph for this function:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_hour ( const int64_t  lcltime)

Definition at line 49 of file ExtractFromTime.cpp.

References kSecsPerDay, kSecsPerHour, and unsigned_mod().

Referenced by ExtractFromTime().

49  {
50  return unsigned_mod(lcltime, kSecsPerDay) / kSecsPerHour;
51 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_isodow ( const int64_t  timeval)

Definition at line 167 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

167  {
168  int64_t const days_past_epoch = floor_div(timeval, kSecsPerDay);
169  return unsigned_mod(days_past_epoch + 3, kDaysPerWeek) + 1;
170 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_microsecond ( const int64_t  lcltime)

Definition at line 69 of file ExtractFromTime.cpp.

References kMicroSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

69  {
70  return unsigned_mod(lcltime, kSecsPerMin * kMicroSecsPerSec);
71 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_millisecond ( const int64_t  lcltime)

Definition at line 64 of file ExtractFromTime.cpp.

References kMilliSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

64  {
65  return unsigned_mod(lcltime, kSecsPerMin * kMilliSecsPerSec);
66 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_minute ( const int64_t  lcltime)

Definition at line 54 of file ExtractFromTime.cpp.

References kSecsPerHour, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

54  {
55  return unsigned_mod(lcltime, kSecsPerHour) / kSecsPerMin;
56 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_month ( const int64_t  timeval)

Definition at line 225 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

225  {
226  if (timeval >= 0LL && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
227  return extract_month_fast(timeval);
228  }
229  int64_t const day = floor_div(timeval, kSecsPerDay);
230  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
231  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
232  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
233  unsigned const moy = (5 * doy + 2) / 153;
234  return moy + (moy < 10 ? 3 : -9);
235 }
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)
#define UINT32_MAX

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE int32_t extract_month_fast ( const int64_t  lcltime)

Definition at line 90 of file ExtractFromTime.cpp.

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

Referenced by extract_month().

90  {
91  STATIC_QUAL const uint32_t cumulative_month_epoch_starts[kMonsPerYear] = {0,
92  2678400,
93  5270400,
94  7948800,
95  10540800,
96  13219200,
97  15897600,
98  18489600,
99  21168000,
100  23760000,
101  26438400,
102  29116800};
103  uint32_t seconds_march_1900 = lcltime + kEpochOffsetYear1900 - kSecsJanToMar1900;
104  uint32_t seconds_past_4year_period = seconds_march_1900 % kSecondsPer4YearCycle;
105  uint32_t year_seconds_past_4year_period =
106  (seconds_past_4year_period / kSecondsPerNonLeapYear) * kSecondsPerNonLeapYear;
107  if (seconds_past_4year_period >=
108  kSecondsPer4YearCycle - kUSecsPerDay) { // if we are in Feb 29th
109  year_seconds_past_4year_period -= kSecondsPerNonLeapYear;
110  }
111  uint32_t seconds_past_march =
112  seconds_past_4year_period - year_seconds_past_4year_period;
113  uint32_t month =
114  seconds_past_march / (30 * kUSecsPerDay); // Will make the correct month either be
115  // the guessed month or month before
116  month = month <= 11 ? month : 11;
117  if (cumulative_month_epoch_starts[month] > seconds_past_march) {
118  month--;
119  }
120  return (month + 2) % 12 + 1;
121 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_nanosecond ( const int64_t  lcltime)

Definition at line 74 of file ExtractFromTime.cpp.

References kNanoSecsPerSec, kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

74  {
75  return unsigned_mod(lcltime, kSecsPerMin * kNanoSecsPerSec);
76 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_quarter ( const int64_t  timeval)

Definition at line 238 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

238  {
239  if (timeval >= 0LL && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
240  return extract_quarter_fast(timeval);
241  }
242  constexpr int64_t quarter[12]{1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 1, 1};
243  int64_t const day = floor_div(timeval, kSecsPerDay);
244  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
245  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
246  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
247  unsigned const moy = (5 * doy + 2) / 153;
248  return quarter[moy];
249 }
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)
#define UINT32_MAX

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE int32_t extract_quarter_fast ( const int64_t  lcltime)

Definition at line 123 of file ExtractFromTime.cpp.

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

Referenced by extract_quarter().

123  {
124  STATIC_QUAL const uint32_t cumulative_quarter_epoch_starts[4] = {
125  0, 7776000, 15638400, 23587200};
126  STATIC_QUAL const uint32_t cumulative_quarter_epoch_starts_leap_year[4] = {
127  0, 7862400, 15724800, 23673600};
128  uint32_t seconds_1900 = lcltime + kEpochOffsetYear1900;
129  uint32_t leap_years = (seconds_1900 - kSecsJanToMar1900) / kSecondsPer4YearCycle;
130  uint32_t year = (seconds_1900 - leap_years * kSecsPerDay) / kSecondsPerNonLeapYear;
131  uint32_t base_year_leap_years = (year - 1) / 4;
132  uint32_t base_year_seconds =
133  year * kSecondsPerNonLeapYear + base_year_leap_years * kUSecsPerDay;
134  bool is_leap_year = year % 4 == 0 && year != 0;
135  const uint32_t* quarter_offsets = is_leap_year
136  ? cumulative_quarter_epoch_starts_leap_year
137  : cumulative_quarter_epoch_starts;
138  uint32_t partial_year_seconds = seconds_1900 % base_year_seconds;
139  uint32_t quarter = partial_year_seconds / (90 * kUSecsPerDay);
140  quarter = quarter <= 3 ? quarter : 3;
141  if (quarter_offsets[quarter] > partial_year_seconds) {
142  quarter--;
143  }
144  return quarter + 1;
145 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_quarterday ( const int64_t  lcltime)

Definition at line 86 of file ExtractFromTime.cpp.

References kSecsPerDay, kSecsPerQuarterDay, and unsigned_mod().

Referenced by ExtractFromTime().

86  {
87  return unsigned_mod(lcltime, kSecsPerDay) / kSecsPerQuarterDay + 1;
88 }
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_second ( const int64_t  lcltime)

Definition at line 59 of file ExtractFromTime.cpp.

References kSecsPerMin, and unsigned_mod().

Referenced by ExtractFromTime().

59  {
60  return unsigned_mod(lcltime, kSecsPerMin);
61 }
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:

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

Definition at line 193 of file ExtractFromTime.cpp.

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

193  {
194  int64_t const day = floor_div(timeval, kSecsPerDay);
195  unsigned const doe = unsigned_mod(day - kEpochAdjustedDays, kDaysPer400Years);
196  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
197  unsigned week_start = week_start_from_yoe<OFFSET>(yoe);
198  if (doe < week_start) {
199  if (yoe == 0) {
200  // 2000-03-01 is OFFSET days from start of week, week + 9.
201  return (doe + OFFSET) / 7 + 9;
202  } else {
203  week_start = week_start_from_yoe<OFFSET>(yoe - 1);
204  }
205  }
206  return (doe - week_start) / 7 + 1;
207 }
static constexpr int64_t kSecsPerDay
DEVICE int64_t floor_div(int64_t const dividend, int64_t const divisor)
#define OFFSET
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:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_monday ( const int64_t  timeval)

Definition at line 210 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

210  {
211  return extract_week<MONDAY>(timeval);
212 }

+ Here is the caller graph for this function:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_saturday ( const int64_t  timeval)

Definition at line 220 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

220  {
221  return extract_week<SATURDAY>(timeval);
222 }

+ Here is the caller graph for this function:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_week_sunday ( const int64_t  timeval)

Definition at line 215 of file ExtractFromTime.cpp.

Referenced by ExtractFromTime().

215  {
216  return extract_week<SUNDAY>(timeval);
217 }

+ Here is the caller graph for this function:

RUNTIME_EXPORT ALWAYS_INLINE DEVICE int64_t extract_year ( const int64_t  timeval)

Definition at line 252 of file ExtractFromTime.cpp.

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

Referenced by ExtractFromTime().

252  {
253  if (timeval >= 0LL && timeval <= UINT32_MAX - kEpochOffsetYear1900) {
254  return extract_year_fast(timeval);
255  }
256  int64_t const day = floor_div(timeval, kSecsPerDay);
257  int64_t const era = floor_div(day - kEpochAdjustedDays, kDaysPer400Years);
258  unsigned const doe = day - kEpochAdjustedDays - era * kDaysPer400Years;
259  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
260  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
261  return 2000 + era * 400 + yoe + (MARJAN <= doy);
262 }
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
#define UINT32_MAX
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:

DEVICE int32_t extract_year_fast ( const int64_t  lcltime)

Definition at line 147 of file ExtractFromTime.cpp.

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

Referenced by extract_year().

147  {
148  const uint32_t seconds_1900 = lcltime + kEpochOffsetYear1900;
149  const uint32_t leap_years = (seconds_1900 - kSecsJanToMar1900) / kSecondsPer4YearCycle;
150  const uint32_t year =
151  (seconds_1900 - leap_years * kUSecsPerDay) / kSecondsPerNonLeapYear + 1900;
152  return year;
153 }
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:

DEVICE int64_t ExtractFromTime ( ExtractField  field,
const int64_t  timeval 
)

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

267  {
268  switch (field) {
269  case kEPOCH:
270  return extract_epoch(timeval);
271  case kDATEEPOCH:
272  return extract_dateepoch(timeval);
273  case kQUARTERDAY:
274  return extract_quarterday(timeval);
275  case kHOUR:
276  return extract_hour(timeval);
277  case kMINUTE:
278  return extract_minute(timeval);
279  case kSECOND:
280  return extract_second(timeval);
281  case kMILLISECOND:
282  return extract_millisecond(timeval);
283  case kMICROSECOND:
284  return extract_microsecond(timeval);
285  case kNANOSECOND:
286  return extract_nanosecond(timeval);
287  case kDOW:
288  return extract_dow(timeval);
289  case kISODOW:
290  return extract_isodow(timeval);
291  case kDAY:
292  return extract_day(timeval);
293  case kWEEK:
294  return extract_week_monday(timeval);
295  case kWEEK_SUNDAY:
296  return extract_week_sunday(timeval);
297  case kWEEK_SATURDAY:
298  return extract_week_saturday(timeval);
299  case kDOY:
300  return extract_day_of_year(timeval);
301  case kMONTH:
302  return extract_month(timeval);
303  case kQUARTER:
304  return extract_quarter(timeval);
305  case kYEAR:
306  return extract_year(timeval);
307  }
308 
309 #ifdef __CUDACC__
310  return -1;
311 #else
312  abort();
313 #endif
314 }
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)
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_hour(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: