OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{DateTruncate.cpp}::EraTime Struct Reference

Public Types

enum  Field {
  ERA, YOE, MOY, DOM,
  SOD
}
 

Public Member Functions

DEVICE EraTime operator- () const
 
DEVICE EraTime operator- (EraTime const &rhs)
 
DEVICE int sign (Field const field) const
 
DEVICE int64_t count (DatetruncField const field) const
 

Static Public Member Functions

static DEVICE EraTime make (int64_t const time)
 

Public Attributes

int64_t const era
 
int const yoe
 
int const moy
 
int const dom
 
int const sod
 

Detailed Description

Definition at line 270 of file DateTruncate.cpp.

Member Enumeration Documentation

Member Function Documentation

DEVICE int64_t anonymous_namespace{DateTruncate.cpp}::EraTime::count ( DatetruncField const  field) const
inline

Definition at line 324 of file DateTruncate.cpp.

References dtCENTURY, dtDECADE, dtMILLENNIUM, dtMONTH, dtQUARTER, dtYEAR, era, moy, sign(), and yoe.

324  {
325  int const sgn = sign(ERA);
326  EraTime const ut = sgn == -1 ? -*this : *this; // Unsigned time
327  switch (field) {
328  case dtMONTH:
329  return sgn * (12 * (400 * ut.era + ut.yoe) + ut.moy - (ut.sign(DOM) == -1));
330  case dtQUARTER: {
331  int const quarters = ut.moy / 3;
332  int const rem = ut.moy % 3;
333  return sgn * (4 * (400 * ut.era + ut.yoe) + quarters -
334  (rem < 0 || (rem == 0 && ut.sign(DOM) == -1)));
335  }
336  case dtYEAR:
337  return sgn * (400 * ut.era + ut.yoe - (ut.sign(MOY) == -1));
338  case dtDECADE: {
339  uint64_t const decades = (400 * ut.era + ut.yoe) / 10;
340  unsigned const rem = (400 * ut.era + ut.yoe) % 10;
341  return sgn * (decades - (rem == 0 && ut.sign(MOY) == -1));
342  }
343  case dtCENTURY: {
344  uint64_t const centuries = (400 * ut.era + ut.yoe) / 100;
345  unsigned const rem = (400 * ut.era + ut.yoe) % 100;
346  return sgn * (centuries - (rem == 0 && ut.sign(MOY) == -1));
347  }
348  case dtMILLENNIUM: {
349  uint64_t const millennia = (400 * ut.era + ut.yoe) / 1000;
350  unsigned const rem = (400 * ut.era + ut.yoe) % 1000;
351  return sgn * (millennia - (rem == 0 && ut.sign(MOY) == -1));
352  }
353  default:
354 #ifdef __CUDACC__
355  return std::numeric_limits<int64_t>::min();
356 #else
357  abort();
358 #endif
359  }
360  }
DEVICE int sign(Field const field) const
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the call graph for this function:

static DEVICE EraTime anonymous_namespace{DateTruncate.cpp}::EraTime::make ( int64_t const  time)
inlinestatic

Definition at line 277 of file DateTruncate.cpp.

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

277  {
278  int64_t const day = floor_div(time, kSecsPerDay);
279  int64_t const era = floor_div(day - kEpochAdjustedDays, kDaysPer400Years);
280  int const sod = time - day * kSecsPerDay;
281  int const doe = day - kEpochAdjustedDays - era * kDaysPer400Years;
282  int const yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
283  int const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
284  int const moy = (5 * doy + 2) / 153;
285  int const dom = doy - (153 * moy + 2) / 5;
286  return {era, yoe, moy, dom, sod};
287  }
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

+ Here is the call graph for this function:

DEVICE EraTime anonymous_namespace{DateTruncate.cpp}::EraTime::operator- ( ) const
inline
DEVICE EraTime anonymous_namespace{DateTruncate.cpp}::EraTime::operator- ( EraTime const &  rhs)
inline

Definition at line 291 of file DateTruncate.cpp.

References dom, era, moy, sod, and yoe.

DEVICE int anonymous_namespace{DateTruncate.cpp}::EraTime::sign ( Field const  field) const
inline

Definition at line 297 of file DateTruncate.cpp.

Referenced by count().

297  {
298  switch (field) {
299  case ERA:
300  if (era != 0) {
301  return era < 0 ? -1 : 1;
302  }
303  case YOE:
304  if (yoe != 0) {
305  return yoe < 0 ? -1 : 1;
306  }
307  case MOY:
308  if (moy != 0) {
309  return moy < 0 ? -1 : 1;
310  }
311  case DOM:
312  if (dom != 0) {
313  return dom < 0 ? -1 : 1;
314  }
315  case SOD:
316  if (sod != 0) {
317  return sod < 0 ? -1 : 1;
318  }
319  default:
320  return 0;
321  }
322  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the caller graph for this function:

Member Data Documentation

int const anonymous_namespace{DateTruncate.cpp}::EraTime::dom

Definition at line 274 of file DateTruncate.cpp.

Referenced by operator-().

int64_t const anonymous_namespace{DateTruncate.cpp}::EraTime::era

Definition at line 271 of file DateTruncate.cpp.

Referenced by count(), and operator-().

int const anonymous_namespace{DateTruncate.cpp}::EraTime::moy

Definition at line 273 of file DateTruncate.cpp.

Referenced by count(), and operator-().

int const anonymous_namespace{DateTruncate.cpp}::EraTime::sod

Definition at line 275 of file DateTruncate.cpp.

Referenced by operator-().

int const anonymous_namespace{DateTruncate.cpp}::EraTime::yoe

Definition at line 272 of file DateTruncate.cpp.

Referenced by count(), and operator-().


The documentation for this struct was generated from the following file: