OmniSciDB  471d68cefb
 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 301 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 355 of file DateTruncate.cpp.

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

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

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

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

Referenced by count().

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

Referenced by operator-().

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

Definition at line 302 of file DateTruncate.cpp.

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

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

Definition at line 304 of file DateTruncate.cpp.

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

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

Definition at line 306 of file DateTruncate.cpp.

Referenced by operator-().

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

Definition at line 303 of file DateTruncate.cpp.

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


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