30 ONIXS_CMEMDH_DATA_PACKING_BEGIN(1)
38 return 86400000000000ll;
44 return 3600000000000ll;
144 TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
146 static_cast<Ticks>(days) *
TimeTraits::nanosecondsPerDay()
147 + static_cast<Ticks>(hours) *
TimeTraits::nanosecondsPerHour()
148 + static_cast<Ticks>(minutes) *
TimeTraits::nanosecondsPerMinute()
149 + static_cast<Ticks>(seconds) *
TimeTraits::nanosecondsPerSecond() + nanoseconds
161 TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
163 static_cast<Ticks>(hours) *
TimeTraits::nanosecondsPerHour()
164 + static_cast<Ticks>(minutes) *
TimeTraits::nanosecondsPerMinute()
165 + static_cast<Ticks>(seconds) *
TimeTraits::nanosecondsPerSecond() + nanoseconds
172 : ticks_(other.ticks_)
180 return static_cast<Days
>(ticks_ / TimeTraits::nanosecondsPerDay());
187 return static_cast<Hours
>((ticks_ / TimeTraits::nanosecondsPerHour()) % TimeTraits::hoursPerDay());
194 return static_cast<Minutes
>((ticks_ / TimeTraits::nanosecondsPerMinute()) % TimeTraits::minutesPerHour());
201 return static_cast<Seconds
>((ticks_ / TimeTraits::nanosecondsPerSecond()) % TimeTraits::secondsPerMinute());
208 return static_cast<Milliseconds
>(
209 (ticks_ / TimeTraits::nanosecondsPerMillisecond()) % TimeTraits::millisecondsPerSecond()
217 return static_cast<Microseconds
>(
218 (ticks_ / TimeTraits::nanosecondsPerMicrosecond()) % TimeTraits::microsecondsPerSecond()
226 return static_cast<Nanoseconds
>(ticks_ % TimeTraits::nanosecondsPerSecond());
242 ticks_ += other.ticks_;
250 ticks_ -= other.ticks_;
258 ticks_ = other.ticks_;
266 std::swap(ticks_, other.ticks_);
332 case TimeSpanFormat::HHMMSS:
336 case TimeSpanFormat::HHMMSSmsec:
340 case TimeSpanFormat::SDHHMMSSnsec:
346 throw std::invalid_argument(
"Unknown timespan format pattern specified. ");
356 toStr(str, timeSpan, format);
438 Nanosecond nanosecond = 0
440 : sinceEpoch_(toTicks(year, month, day, hour, minute, second, nanosecond))
451 toDate(sinceEpoch_, year, month, day);
463 toDate(sinceEpoch_, year, month, day);
475 toDate(sinceEpoch_, year, month, day);
483 return static_cast<Hour
>(time().hours());
489 return static_cast<Minute
>(time().minutes());
495 return static_cast<Second
>(time().seconds());
501 return static_cast<Millisecond
>(time().milliseconds());
507 return static_cast<Microsecond
>(time().microseconds());
513 return static_cast<Nanosecond
>(time().nanoseconds());
519 return Timestamp(sinceEpoch_ - sinceEpoch_ % TimeTraits::nanosecondsPerDay());
525 return TimeSpan(sinceEpoch_ % TimeTraits::nanosecondsPerDay());
537 std::swap(sinceEpoch_, other.sinceEpoch_);
546 static Ticks toTicks(Year, Month, Day, Hour, Minute, Second, Nanosecond);
550 static void toDate(Ticks, Year&, Month&, Day&);
650 case TimestampFormat::YYYYMMDD:
654 case TimestampFormat::YYYYMMDDHHMMSS:
658 case TimestampFormat::YYYYMMDDHHMMSSmsec:
662 case TimestampFormat::YYYYMMDDHHMMSSnsec:
668 throw std::invalid_argument(
"Unknown timestamp format pattern specified. ");
678 toStr(str, timestamp, format);
689 return fromStr(ts, str.c_str(), str.size());
692 ONIXS_CMEMDH_DATA_PACKING_END
Ticks ticks() const
Number of ticks in given time interval.
Microsecond microsecond() const
Microsecond component of given time point.
static Int64 nanosecondsPerDay()
Returns number of nanoseconds in single day.
TimeSpan & operator=(const TimeSpan &other)
Reinitializes as copy of given instance.
static Int32 millisecondsPerSecond()
Returns number of milliseconds in single second.
void toStrAsHHMMSSmsec(std::string &, TimeSpan)
Timestamp(Ticks ticks=0)
Initializes from number of ticks since epoch.
Milliseconds milliseconds() const
Milliseconds component of time interval.
Microseconds microseconds() const
Microseconds component of time interval.
void toStrAsYYYYMMDDHHMMSSnsec(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSSnsec format.
bool fromStr(Timestamp &ts, const std::string &str)
static Int32 nanosecondsPerMicrosecond()
Returns number of nanoseconds in single microsecond.
UInt32 Day
Integral type presenting day component.
Int32 Hours
Integral type for number of hours.
static Int64 nanosecondsPerMinute()
Returns number of nanoseconds in single minute.
bool operator>=(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
Days days() const
Days component of time interval.
Represents time point without time-zone information.
Hours hours() const
Hours component of time interval.
Identifies months in year.
static Int32 microsecondsPerSecond()
Returns number of microseconds in single second.
Int64 Ticks
Integral type presenting internal ticks.
Timestamp date() const
Timestamp without a time part.
Timestamp timestamp(const MultiContainer &, Tag)
Retrieves last update time field value.
TimeSpan & operator-=(const TimeSpan &other)
Subtracts time interval from current one.
static Int32 minutesPerHour()
Returns number of minutes in single hour.
Year year() const
Year component of given time point.
UInt32 Nanosecond
Integral type presenting nanosecond component.
#define ONIXS_CMEMDH_LTWT
TimeSpan(const TimeSpan &other)
Initializes instance as a copy of the other one.
Int32 Nanoseconds
Integral type for number of nanoseconds.
Millisecond millisecond() const
Millisecond component of given time point.
Ticks sinceEpoch() const
Number of nanoseconds since the Epoch (01-01-1970).
Second second() const
Second component of given time point.
char Char
Character type alias.
void toStrAsHHMMSS(std::string &, TimeSpan)
UInt32 Hour
Integral type presenting hour component.
Int32 Milliseconds
Integral type for number of milliseconds.
bool operator<(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
void toStrAsSDHHMMSSnsec(std::string &, TimeSpan)
Hour hour() const
Hour component of given time point.
Int32 minutes() const
Minutes component of time interval.
TimeSpan(Ticks ticks=0)
Initializes timespan from given number of ticks.
Nanoseconds nanoseconds() const
Nanoseconds component of time interval.
Represents time interval.
Int32 seconds() const
Seconds component of time interval.
static Int32 hoursPerDay()
Returns number of hours in single day.
bool operator<=(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
UInt32 Second
Integral type presenting second component.
void toStrAsYYYYMMDD(std::string &, Timestamp)
Serializes timestamp in YYYYMMDD format.
Timestamp operator+(const Timestamp ×tamp, const TimeSpan &timeSpan)
Adds time interval to given time point.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
UInt32 Minute
Integral type presenting minute component.
Int32 Seconds
Integral type for number of seconds.
void swap(TimeSpan &other)
Exchanges with given instance.
UInt32 Microsecond
Integral type presenting microsecond component.
Int32 Microseconds
Integral type for number of microseconds.
#define ONIXS_CMEMDH_EXPORTED
UInt32 Base
Defines numeric value sufficient to hold enumeration values.
bool operator>(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
TimeSpan time() const
Time part of timestamp.
UInt64 Ticks
Integral type storing internal ticks.
TimeSpan operator-(const Timestamp &left, const Timestamp &right)
Calculates time interval between two time points.
#define ONIXS_CMEMDH_LTWT_EXPORTED
UInt32 Year
Integral type presenting year component.
void toStrAsYYYYMMDDHHMMSS(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSS format.
Miscellaneous time characteristics.
TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
Initializes with given set of values.
void swap(Timestamp &other)
Exchanges value with other instance.
Nanosecond nanosecond() const
Nanosecond component of given time point.
Timestamp(Year year, Month month, Day day, Hour hour=0, Minute minute=0, Second second=0, Nanosecond nanosecond=0)
Explicit time-stamp initialization.
static Int32 nanosecondsPerMillisecond()
Returns number of nanoseconds in single millisecond.
std::string toStr(Timestamp timestamp, TimestampFormat::Enum format=TimestampFormat::YYYYMMDDHHMMSSnsec)
Serializes timestamp according to specified pattern.
void toStrAsYYYYMMDDHHMMSSmsec(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSSmsec format.
static Int32 secondsPerMinute()
Returns number of seconds in single minute.
static Int64 nanosecondsPerHour()
Returns number of nanoseconds in single hour.
bool operator!=(const Timestamp &left, const Timestamp &right)
Compares with instances for inequality.
Month month() const
Month component of given time point.
bool operator==(const Timestamp &left, const Timestamp &right)
Compares with instances for equality.
TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
Initializes with given set of values.
Day day() const
Day component of given time point.
TimeSpan & operator+=(const TimeSpan &other)
Adds time interval to current one.
Minute minute() const
Minute component of given time point.
Int32 Minutes
Integral type for number of minutes.
Enum
Identifies months in year.
OnixS::CME::MDH::Month::Enum Month
Type presenting month component.
Int32 Days
Integral type for number of days.
UInt32 Millisecond
Integral type presenting millisecond component.
static Int32 nanosecondsPerSecond()
Returns number of nanoseconds in single second.
#define ONIXS_CMEMDH_NAMESPACE_END