OSB_LIB::DateTime Class Reference

Collaboration diagram for OSB_LIB::DateTime:

Collaboration graph
[legend]
List of all members.

Detailed Description

Support for timestamps (date and time).

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.

Public Member Functions

Read access functions
DateTime arithemtics functions.
DateTime arithemtics operators.
Comparison operator.

Static Public Member Functions

Special timestamps.

Private Member Functions

Private Attributes

Classes


Constructor & Destructor Documentation

OSB_LIB::DateTime::DateTime (  )  [inline]

Default constructor.

Definition at line 435 of file chrono.h.

Referenced by max(), and min().

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.

Exceptions:
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_.

OSB_LIB::DateTime::DateTime ( time_t  sec,
Offset  offset = Offset() 
) [explicit]

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.

Parameters:
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.
If the offset is defined then date and time are interpreted as the wall clock time at the location East of UTC.


Member Function Documentation

DateTime& OSB_LIB::DateTime::addDays ( long   ) 

Add n days.

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::addSeconds ( long   ) 

Add seconds.

Referenced by OSB_LIB::PersProductCache::Key::mkAssignPeriod().

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]

Returns date.

Definition at line 517 of file chrono.h.

References d_.

int OSB_LIB::DateTime::day (  )  const

Returns day.

long OSB_LIB::DateTime::getTimezone (  )  [inline, static]

Get seconds East of UTC.

Definition at line 722 of file chrono.h.

int OSB_LIB::DateTime::hour (  )  const

Returns hour.

bool OSB_LIB::DateTime::isSet (  )  const [inline]

Timestamp set?

Returns:
true if d_ (see Date::isSet()) is set, else false.

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?

Returns:
true if d_ (see Date::notSet()) is not set, else false.

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!=.

DateTime& OSB_LIB::DateTime::operator+ ( const Time  ) 

Add time operator.

DateTime& OSB_LIB::DateTime::operator+= ( const Time  ) 

Add time operator.

DateTime& OSB_LIB::DateTime::operator- ( const Time  ) 

Subtract operator.

DateTime& OSB_LIB::DateTime::operator-= ( const Time  ) 

Subtract 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]

Returns time.

Definition at line 519 of file chrono.h.

References t_.

int OSB_LIB::DateTime::year (  )  const

Returns year.


Member Data Documentation

Date OSB_LIB::DateTime::d_ [private]

Date object.

Definition at line 616 of file chrono.h.

Referenced by date(), isSet(), and notSet().

Offset OSB_LIB::DateTime::offset_ [private]

Seconds east of UTC.

Definition at line 620 of file chrono.h.

Referenced by DateTime().

Time OSB_LIB::DateTime::t_ [private]

Time object.

Definition at line 618 of file chrono.h.

Referenced by time().


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:11:02 2006 for OSB Library by  doxygen 1.4.7