OSB_LIB::TimeZone Class Reference

Collaboration diagram for OSB_LIB::TimeZone:

Collaboration graph
[legend]
List of all members.

Detailed Description

Calculates the difference between the localtime and GMT.

This class will take care of daylight saving time into the consideration and calculates the offset between the localtime and GMT.

Definition at line 66 of file timezone.h.

Public Types

Public Member Functions

Read access to data members.
Database operations:

Private Member Functions

Private Attributes

Friends

Classes


Member Typedef Documentation

typedef std::vector<Interval> OSB_LIB::TimeZone::Intervals

Container for the interval.

Definition at line 90 of file timezone.h.

typedef Id<TimeZone> OSB_LIB::TimeZone::Oid

Unique object identification.

Definition at line 75 of file timezone.h.


Constructor & Destructor Documentation

OSB_LIB::TimeZone::TimeZone ( const Oid oid,
const std::string &  name,
const std::string &  dstStart,
const std::string &  dstStartTime,
const std::string &  dstEnd,
const std::string &  dstEndTime,
long  stdOffset,
long  dstOffset 
)

Constructor to construct with all timezone informations.

This will configure this object with the given value. The dstStart and dstEnd is having the format of m.n.d where m is the month, n is the week and d is day. It means dth day of nth week in month m. If the value of n is 5 means last dth day of month m irrespective of 4 week or 5 week, d is 1 for Monday and 7 for sunday. The dstStartTime and dstEndTime is having the format of HH[:MM[:SS]].

Parameters:
oid Unique object identifier for timezone.
name Name of the object.
dstStart Start date of the DST period.
dstStartTime The time when the dst starts on the dstStart date.
dstEnd End date of the DST period.
dstEndTime The time when the dst ends on the dstEnd date.
stdOffset Difference between the std time and GMT in seconds.
dstOffset Difference between the dst time and GMT in seconds.

OSB_LIB::TimeZone::TimeZone ( const Oid oid = Oid()  )  [explicit]

Default constructor only with optional object id.

It assumes the difference between the local time and GMT as the standard offset.

Parameters:
oid Unique object identifier for timezone.


Member Function Documentation

const std::string& OSB_LIB::TimeZone::dstEnd (  )  const

Returns the end date of the DST in m.n.d format.

const std::string& OSB_LIB::TimeZone::dstEndTime (  )  const

Returns the DST end time in HH[:MM[:SS]] format.

long OSB_LIB::TimeZone::dstOffset (  )  const

Difference between daylight saving time and GMT.

Exceptions:
Undefined 

const std::string& OSB_LIB::TimeZone::dstStart (  )  const

Returns the start date of the DST in m.n.d format.

const std::string& OSB_LIB::TimeZone::dstStartTime (  )  const

Returns the DST start time in HH[:MM[:SS]] format.

long OSB_LIB::TimeZone::find ( const DateTime ts  )  const [private]

Finds the interval for the given timestamp.

Parameters:
ts The timestamp for which the offset is required.
Returns:
Index of the interval in intervals_, -1 if no matching interval is found.

bool OSB_LIB::TimeZone::insert ( const OSB_DB::Session session  ) 

Insert the timezone into the database.

This will insert the timezone into the database using timezone gateway. All the attributes except object identifier should be filled before insertion. The object identifier should be assigned after the successful insertion into the database.

Parameters:
session Database session to use.
Exceptions:
Exception on general database error.
Returns:
True if object inserted successfully else false.

const TimeZone::Intervals& OSB_LIB::TimeZone::intervals (  )  const [private]

Returns the interval array.

DateTime OSB_LIB::TimeZone::mkDateTime ( std::string &  dstDate,
std::string &  dstTime,
int  year 
) [private]

It creates a datetime for the given information.

It parse the given dstDate, dstTime and configure the values to the datetime and returns the same.

Parameters:
dstDate The string which is used to configure the date in the datetime.
dstTime The string which is used to configure the time in the datetime.
year The year to be configured in the datetime.
Returns:
Returns a reference to the datetime object which is configured using the given informations.

DateTime OSB_LIB::TimeZone::mkDstEnd ( int  year  )  [private]

It makes the DST end period for the given year.

It use the dstEnd_, dstEndTime_ and year to make the dst end period. It uses the function mkDateTime to create this datetime for the given information.

Parameters:
year The year for which the DST end period required.
Returns:
Returns the dstEnd for the year.

DateTime OSB_LIB::TimeZone::mkDstStart ( int  year  )  [private]

It makes the DST start period for the given year.

It use the dststart_, dstStartTime_ and year to make the dst start period. It uses the function mkDateTime to create this datetime for the given information.

Parameters:
year The year for which the DST start period required.
Returns:
Returns the dstStart for the year.

long OSB_LIB::TimeZone::mkInterval ( const DateTime ts  )  [private]

Makes the interval for the given datetime object.

It takes the year from the given datetime object.It creates a interval using the dstStart, dstStartTime, dstEnd and dstEndTime, dstOffset. If the given datetime is lying in this interval then this interval will be pushed into the interval container and the position will be returned. If the given datetime object is less then the interval is made for the dstEnd of previous year, the dstStart of current year and the offset is the stdOffset. This interval will be pushed into the container and the position will be returned.

Parameters:
ts The datetime for which the interval has to be defined.
Returns:
Index of the newly created interval in intervals_.

const std::string& OSB_LIB::TimeZone::name (  )  const

Returns the name of the object.

void OSB_LIB::TimeZone::normalize ( DateTime ts  ) 

This will normalize the ts to STD or DST using the offset.

Parameters:
ts The datetime object to use.
Exceptions:
Undefined 
              Assume the DST starts on first sunday of april and ends
          at first sunday of october. The time will be shifted to
          one hour more at the dst Start and will be back one hour at
          the dst end. The datetime <i>ts</i> will be normalized
          as follows:


                          7-4-2002 03:00:00    6-10-2002 01:59:59
                                   |--------------|
          1-1-2002 00:00:01                          31-12-2002 00:00:00
                  |---------------|             |----------------|
                       7-4-2002 01:59:59   6-10-2002 01:00:00

          The line at the top is the DST time period of the year 2002
          and the bottom two lines are the STD time periods.

          Assume DST offset = -18000, STD offset = -21600

          Input 1:
              If the datetime <i>ts</i> is 7-4-2002 01:30:00[GMT-6:00]
              with offset -21600. The datetime is available in the STD
              time period, so it won't change the <i>ts</i>.

          Input 2:
              If the datetime <i>ts</i> is 7-4-2002 02:30:00[GMT-6:00]
              with offset -21600. This datetime is not exist in the STD
              time period. So this normalize the datetime to DST time
              period as 7-4-2002 03:30:00 [GMT-5:00].

          Input 3:
              If the datetime <i>ts</i> is 7-4-2002 03:30:00[GMT-6:00]
              with offset -21600. This datetime is not exist in the STD
              time period. So this normalize the datetime to DST time
              period as 7-4-2002 04:30:00 [GMT-5:00].

          Input 4:
              If the datetime <i>ts</i> is 7-4-2002 02:30:00[GMT-5:00]
              with the offset -18000. The datetime is not exist in the
              DST time period. So this will normalize to STD time period
              as 7-4-2002 01:30:00[GMT-6:00].

          Input 5:
              If the datetime <i>ts</i> is 7-4-2002 03:30:00[GMT-5:00]
              with the offset -18000. The datetime is exist in the DST
              time period, so it won't change the <i>ts</i>.

          Input 6:
              If the datetime <i>ts</i> is 6-10-2002 01:30:00[GMT-5:00]
              with the offset -18000. The datetime is exist in the DST
              time period, so it won't change the <i>ts</i>.

          Input 7:
              If the datetime <i>ts</i> is 6-10-2002 02:30:00[GMT-5:00]
              with the offset -18000. The datetime is not exist in the
              DST time period so it will be normalized to the STD time
              period as 6-10-2002 01:30:00[GMT-6:00].

          All other inputs will come in any one of the above category.

long OSB_LIB::TimeZone::offset ( DateTime ts  ) 

This will return the offset to the GMT in seconds.

It finds the interval for the given datetime. If there is no interval for the given datetime then it will create a interval and returns the offset of that interval. The new offset will be assigned to ts. Existing offset will not be considered.

Parameters:
ts The datetime object to use.
Exceptions:
Undefined 
Returns:
Difference between the GMT and the given datetime.

const Oid& OSB_LIB::TimeZone::oid (  )  const

Returns the unique object identifier.

bool OSB_LIB::TimeZone::read ( const OSB_DB::Session session  ) 

Read the timezone from the database.

This will read the timezone informations from the database using timezone gateway. The object identifier is used to identify the timezone. Before calling this function the object identifier should be set. All the remaining attributes are filled from the database.

Parameters:
session Database session to use.
Exceptions:
Exception if object not found.
Returns:
True if the object read successfully else false.

bool OSB_LIB::TimeZone::remove ( const OSB_DB::Session session  ) 

Remove the timezone in the database.

This will remove the timezone object from the database using timezone gateway. Before executing this function the object identifier should be filled to identify the object in the database.

Parameters:
session Database session to use.
Exceptions:
Exception if object not found.
Returns:
True if object removed successfully else false.

long OSB_LIB::TimeZone::stdOffset (  )  const

Difference between standard time and GMT.

Exceptions:
Undefined 


Friends And Related Function Documentation

friend struct OSB_DB::TimeZoneGw [friend]

It fills all the private attributes on read. It will perform all the database operations for the TimeZone.

Definition at line 72 of file timezone.h.


Member Data Documentation

std::string OSB_LIB::TimeZone::dstEnd_ [private]

End date in the given string format.

Definition at line 336 of file timezone.h.

std::string OSB_LIB::TimeZone::dstEndTime_ [private]

Time when the DST starts on the given date.

Definition at line 339 of file timezone.h.

long OSB_LIB::TimeZone::dstOffset_ [private]

Difference between the normal time and GMT in seconds.

Definition at line 345 of file timezone.h.

std::string OSB_LIB::TimeZone::dstStart_ [private]

Start date in the given string format.

Definition at line 330 of file timezone.h.

std::string OSB_LIB::TimeZone::dstStartTime_ [private]

Time when the DST starts on the given date.

Definition at line 333 of file timezone.h.

Intervals OSB_LIB::TimeZone::intervals_ [mutable, private]

Container for the interval.

Definition at line 348 of file timezone.h.

std::string OSB_LIB::TimeZone::name_ [private]

Name of the object.

Definition at line 327 of file timezone.h.

Oid OSB_LIB::TimeZone::oid_ [private]

Unique object identifier.

Definition at line 324 of file timezone.h.

long OSB_LIB::TimeZone::stdOffset_ [private]

Difference between the normal time and the GMT in seconds.

Definition at line 342 of file timezone.h.


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