OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 302 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 356 of file DateTruncate.cpp.

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

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

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

309  {
310  int64_t const day = floor_div(time, kSecsPerDay);
311  int64_t const era = floor_div(day - kEpochAdjustedDays, kDaysPer400Years);
312  int const sod = time - day * kSecsPerDay;
313  int const doe = day - kEpochAdjustedDays - era * kDaysPer400Years;
314  int const yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
315  int const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
316  int const moy = (5 * doy + 2) / 153;
317  int const dom = doy - (153 * moy + 2) / 5;
318  return {era, yoe, moy, dom, sod};
319  }
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 323 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 329 of file DateTruncate.cpp.

Referenced by count().

329  {
330  switch (field) {
331  case ERA:
332  if (era != 0) {
333  return era < 0 ? -1 : 1;
334  }
335  case YOE:
336  if (yoe != 0) {
337  return yoe < 0 ? -1 : 1;
338  }
339  case MOY:
340  if (moy != 0) {
341  return moy < 0 ? -1 : 1;
342  }
343  case DOM:
344  if (dom != 0) {
345  return dom < 0 ? -1 : 1;
346  }
347  case SOD:
348  if (sod != 0) {
349  return sod < 0 ? -1 : 1;
350  }
351  default:
352  return 0;
353  }
354  }
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 306 of file DateTruncate.cpp.

Referenced by operator-().

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

Definition at line 303 of file DateTruncate.cpp.

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

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

Definition at line 305 of file DateTruncate.cpp.

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

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

Definition at line 307 of file DateTruncate.cpp.

Referenced by operator-().

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

Definition at line 304 of file DateTruncate.cpp.

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


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