992
994
* Comparison operators between two Timestamps
994
bool Date::operator==(const Timestamp& rhs)
996
bool Timestamp::operator==(const Timestamp& rhs)
996
998
return (_epoch_seconds == rhs._epoch_seconds);
998
bool Date::operator!=(const Timestamp& rhs)
1000
bool Timestamp::operator!=(const Timestamp& rhs)
1000
1002
return ! (*this == rhs);
1002
bool Date::operator<(const Timestamp& rhs)
1004
bool Timestamp::operator<(const Timestamp& rhs)
1004
1006
return (_epoch_seconds < rhs._epoch_seconds);
1006
bool Date::operator<=(const Timestamp& rhs)
1008
bool Timestamp::operator<=(const Timestamp& rhs)
1008
1010
return (_epoch_seconds <= rhs._epoch_seconds);
1010
bool Date::operator>(const Timestamp& rhs)
1012
bool Timestamp::operator>(const Timestamp& rhs)
1012
1014
return ! (*this < rhs);
1014
bool Date::operator>=(const Timestamp& rhs)
1016
bool Timestamp::operator>=(const Timestamp& rhs)
1016
1018
return ! (*this <= rhs);
1022
* Push the contents of the timestamp into the output stream
1023
* as a formatted Timestamp value.
1025
* @TODO This unfortunately fails in a weird way...even with std::noskipws,
1026
* the output stream only reads up to the space in the string... :(
1028
std::ostream& operator<<(std::ostream& os, const Timestamp& subject)
1030
return os << subject.years() << '-'
1031
<< std::setw(2) << std::setfill('0') << subject.months() << '-'
1032
<< std::setw(2) << std::setfill('0') << subject.days() << ' '
1033
<< std::setw(2) << std::setfill('0') << subject.hours() << ':'
1034
<< std::setw(2) << std::setfill('0') << subject.minutes() << ':'
1035
<< std::setw(2) << std::setfill('0') << subject.seconds();
1019
1038
bool Time::from_string(const char *from, size_t from_len)
1429
1448
bool Timestamp::is_valid() const
1431
return in_unix_epoch_range(_years, _months, _days, _hours, _minutes, _seconds);
1450
return DateTime::is_valid()
1451
&& in_unix_epoch_range(_years, _months, _days, _hours, _minutes, _seconds);
1434
1454
bool MicroTimestamp::is_valid() const
1436
return in_unix_epoch_range(_years, _months, _days, _hours, _minutes, _seconds)
1456
return Timestamp::is_valid()
1437
1457
&& (_useconds <= UINT32_C(999999));
1440
1460
bool NanoTimestamp::is_valid() const
1442
return in_unix_epoch_range(_years, _months, _days, _hours, _minutes, _seconds)
1462
return Timestamp::is_valid()
1443
1463
&& (_useconds <= UINT32_C(999999))
1444
1464
&& (_nseconds <= UINT32_C(999999999));