OmniSciDB  bf83d84833
 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 294 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 348 of file DateTruncate.cpp.

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

348  {
349  int const sgn = sign(ERA);
350  EraTime const ut = sgn == -1 ? -*this : *this; // Unsigned time
351  switch (field) {
352  case dtMONTH:
353  return sgn * (12 * (400 * ut.era + ut.yoe) + ut.moy - (ut.sign(DOM) == -1));
354  case dtQUARTER: {
355  int const quarters = ut.moy / 3;
356  int const rem = ut.moy % 3;
357  return sgn * (4 * (400 * ut.era + ut.yoe) + quarters -
358  (rem < 0 || (rem == 0 && ut.sign(DOM) == -1)));
359  }
360  case dtYEAR:
361  return sgn * (400 * ut.era + ut.yoe - (ut.sign(MOY) == -1));
362  case dtDECADE: {
363  uint64_t const decades = (400 * ut.era + ut.yoe) / 10;
364  unsigned const rem = (400 * ut.era + ut.yoe) % 10;
365  return sgn * (decades - (rem == 0 && ut.sign(MOY) == -1));
366  }
367  case dtCENTURY: {
368  uint64_t const centuries = (400 * ut.era + ut.yoe) / 100;
369  unsigned const rem = (400 * ut.era + ut.yoe) % 100;
370  return sgn * (centuries - (rem == 0 && ut.sign(MOY) == -1));
371  }
372  case dtMILLENNIUM: {
373  uint64_t const millennia = (400 * ut.era + ut.yoe) / 1000;
374  unsigned const rem = (400 * ut.era + ut.yoe) % 1000;
375  return sgn * (millennia - (rem == 0 && ut.sign(MOY) == -1));
376  }
377  default:
378 #ifdef __CUDACC__
379  return std::numeric_limits<int64_t>::min();
380 #else
381  abort();
382 #endif
383  }
384  }
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 301 of file DateTruncate.cpp.

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

301  {
302  int64_t const day = floor_div(time, kSecsPerDay);
303  int64_t const era = floor_div(day - kEpochAdjustedDays, kDaysPer400Years);
304  int const sod = time - day * kSecsPerDay;
305  int const doe = day - kEpochAdjustedDays - era * kDaysPer400Years;
306  int const yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
307  int const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
308  int const moy = (5 * doy + 2) / 153;
309  int const dom = doy - (153 * moy + 2) / 5;
310  return {era, yoe, moy, dom, sod};
311  }
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 315 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 321 of file DateTruncate.cpp.

Referenced by count().

321  {
322  switch (field) {
323  case ERA:
324  if (era != 0) {
325  return era < 0 ? -1 : 1;
326  }
327  case YOE:
328  if (yoe != 0) {
329  return yoe < 0 ? -1 : 1;
330  }
331  case MOY:
332  if (moy != 0) {
333  return moy < 0 ? -1 : 1;
334  }
335  case DOM:
336  if (dom != 0) {
337  return dom < 0 ? -1 : 1;
338  }
339  case SOD:
340  if (sod != 0) {
341  return sod < 0 ? -1 : 1;
342  }
343  default:
344  return 0;
345  }
346  }
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 298 of file DateTruncate.cpp.

Referenced by operator-().

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

Definition at line 295 of file DateTruncate.cpp.

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

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

Definition at line 297 of file DateTruncate.cpp.

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

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

Definition at line 299 of file DateTruncate.cpp.

Referenced by operator-().

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

Definition at line 296 of file DateTruncate.cpp.

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


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