In OSB timestamps are expressed relative to the system clock: they don't carry timezone or daylight saving time information.
This definition was choosen to allow for fast comparsions.
The member offset_ allows to define a timeshift, expressed in seconds east of UTC.
Definition at line 386 of file chrono.h.
OSB_LIB::DateTime::DateTime | ( | ) | [inline] |
OSB_LIB::DateTime::DateTime | ( | const Date & | date, | |
const Time & | time = Time() , |
|||
Offset | offset = Offset() | |||
) | [inline, explicit] |
Constructor with date, time and optional offset.
If the offset is defined then date and time are interpreted as the wall clock time at the location east of UTC.
OsbException | if date or time are not valid. |
Definition at line 702 of file chrono.h.
References applyOffset(), OSB_LIB::DateTime::Offset::isSet(), normalize(), and offset_.
Construct from time_t.
If no offset is defined sec is converted directly into a local time.
If the offset is defined then date and time are interpreted as the wall clock time at the location east of UTC.
OSB_LIB::DateTime::DateTime | ( | const std::string & | src, | |
const std::string & | format = "%d-%m-%Y %T" , |
|||
Offset | offset = Offset() | |||
) | [explicit] |
Construct from string.
src | String representing the date in format. | |
format | Describes the format of src: "%d-%m-%Y %T" corresponds to "dd-mm-yyyy hh:mm:ss", see man strptime for details. | |
offset | Offset from GMT. |
DateTime& OSB_LIB::DateTime::addHours | ( | int | ) |
Add hours.
DateTime& OSB_LIB::DateTime::addMinutes | ( | int | ) |
Add minutes.
DateTime& OSB_LIB::DateTime::addMonths | ( | int | ) |
Add n months.
DateTime& OSB_LIB::DateTime::addYears | ( | int | ) |
Add n years.
void OSB_LIB::DateTime::applyOffset | ( | ) | [private] |
Apply the offset: moves date and time that are interpreted as UTC time to system clock.
Referenced by DateTime().
const Date& OSB_LIB::DateTime::date | ( | ) | const [inline] |
int OSB_LIB::DateTime::day | ( | ) | const |
Returns day.
long OSB_LIB::DateTime::getTimezone | ( | ) | [inline, static] |
int OSB_LIB::DateTime::hour | ( | ) | const |
Returns hour.
bool OSB_LIB::DateTime::isSet | ( | ) | const [inline] |
Timestamp set?
Definition at line 728 of file chrono.h.
References d_, and OSB_LIB::Date::isSet().
const DateTime OSB_LIB::DateTime::max | ( | ) | [inline, static] |
Largest datetime.
Definition at line 717 of file chrono.h.
References DateTime(), and OSB_LIB::Date::max().
Referenced by OSB_LIB::Period::contains(), OSB_LIB::Period::infinite(), and OSB_LIB::PersProductCache::Key::mkAssignPeriod().
const DateTime OSB_LIB::DateTime::min | ( | ) | [inline, static] |
Smallest datetime.
Definition at line 712 of file chrono.h.
References DateTime(), and OSB_LIB::Date::min().
Referenced by OSB_LIB::Period::contains(), and OSB_LIB::Period::infinite().
int OSB_LIB::DateTime::minute | ( | ) | const |
Returns minute.
Month OSB_LIB::DateTime::month | ( | ) | const |
Returns month.
void OSB_LIB::DateTime::normalize | ( | ) | [private] |
Normalize the time.
While doing arithmetic on the time part, it may get out of boundary (smaller than 00:00:00 or bigger than 23:59:59).
This function normalizes the time by adding or substracting day from/to the day part.
Referenced by DateTime().
bool OSB_LIB::DateTime::notSet | ( | ) | const [inline] |
Timestamp not set?
Definition at line 733 of file chrono.h.
References d_, and OSB_LIB::Date::notSet().
Referenced by OSB_LIB::Period::contains(), and OSB_LIB::BsPage::isOpen().
static DateTime OSB_LIB::DateTime::now | ( | ) | [static] |
Get current system date and time.
const Offset& OSB_LIB::DateTime::offset | ( | ) | const |
Returns offset.
bool OSB_LIB::DateTime::operator!= | ( | const DateTime & | ) | const |
operator!=.
bool OSB_LIB::DateTime::operator< | ( | const DateTime & | ) | const |
operator<.
bool OSB_LIB::DateTime::operator<= | ( | const DateTime & | ) | const |
operator<=.
bool OSB_LIB::DateTime::operator== | ( | const DateTime & | ) | const |
operator==.
bool OSB_LIB::DateTime::operator> | ( | const DateTime & | ) | const |
operator>.
bool OSB_LIB::DateTime::operator>= | ( | const DateTime & | ) | const |
operator>=.
int OSB_LIB::DateTime::second | ( | ) | const |
Returns second.
std::string OSB_LIB::DateTime::str | ( | ) | const |
Returns in format "dd-mm-yyyy hh:mm:ss".
std::string OSB_LIB::DateTime::strLocale | ( | ) | const |
Returns in format "dd-mm-yyyy hh:mm:ss (GMT +hh[:mm[:ss]])".
std::string OSB_LIB::DateTime::strTs | ( | ) | const |
Returns as sortable timestamp: "yyyymmddhhmiss".
std::string OSB_LIB::DateTime::strTsLoc | ( | ) | const |
Returns local wall clock time as sortable string (format "yyyymmddhhmiss").
If the offset is not set the function is equivalent to strTs().
If the offset is set use this function to write and read a DateTime together with Offset::utcOff() to/from a file.
const Time& OSB_LIB::DateTime::time | ( | ) | const [inline] |
int OSB_LIB::DateTime::year | ( | ) | const |
Returns year.
Date OSB_LIB::DateTime::d_ [private] |
Offset OSB_LIB::DateTime::offset_ [private] |
Time OSB_LIB::DateTime::t_ [private] |