Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Zulu Class Reference

Time of day in "zulu" time (i.e. More...

#include <Date.h>

Inheritance diagram for Zulu:

DateZulu SimDate List of all members.

Public Types

typedef double time_t

Public Methods

 Zulu ()
 Default constructor.

 Zulu (int hour, int minute, time_t second, int tz=0)
 Construct a Zulu from the hour, minute, and second.

 Zulu (time_t second, int tz=0)
 Construct a Zulu from the seconds since midnight.

 Zulu (const Zulu &z)
 Copy constructor.

const Zulu & operator= (const Zulu &z)
 Copy operator.

void setTZ (int tz)
 Set the timezone (only effects the local time).

int getTZ () const
 Get the timezone.

int reduce ()
 Wrap time to 24 hour period.

time_t getTime (bool local=false) const
 Get the curret time in seconds since midnight.

bool overflow () const
 Test if the time accumulator exceeds 24 hours.

int getHour (bool local=false) const
 Get the hour.

int getMinute () const
 Get the minute.

int getSecond () const
 Get the second.

int rollover ()
 Adjust the time to fit into the range 0-86400.

int addTime (time_t dt)
 Advance the time, with 24 hour clock rollover.

int setTime (time_t t, bool local=false)
 Set the time.

void convert (struct tm *tm, bool local=false) const
 Extract time from a C tm structure.

std::string formatString (const char *format, bool local=false) const
 Format the time as a string.

virtual std::string asString () const
 Return the time as a string in the form "HH:MM::SSz".

virtual std::string typeString () const
 Return a string representation of the type.


Detailed Description

Time of day in "zulu" time (i.e.

UTC or Greenwich Mean).

Times are stored as doubles in seconds since midnight. This makes time based calculations relatively easy. When the second count exceeds 86400, the day is incremented and the clock reset. Resetting the clock can cause problems with calculations involving changes in time, so care must be taken. The advantage of keeping the clock count small is that precision is not lost for small time intervals. In computing time intervals that should be small, use the SimDate::interval function.

A timezone parameter and options for operating on "local" times are provided. Care must be taken when using these methods in conjunction with dates, since the date may differ depending on whether local or zulu time is used.

Author:
Mark Rose <mrose@stm.lbl.gov>


Member Typedef Documentation

typedef double Zulu::time_t
 


Constructor & Destructor Documentation

Zulu::Zulu   [inline]
 

Default constructor.

Time set to midnight, Greenwich mean.

Zulu::Zulu int    hour,
int    minute,
time_t    second,
int    tz = 0
[inline]
 

Construct a Zulu from the hour, minute, and second.

Parameters:
hour  hour (0-23)
minute  minute (0-59)
second  second (0.0-60.0)
tz  timezone (defaults to Greenwich mean)

Zulu::Zulu time_t    second,
int    tz = 0
[inline]
 

Construct a Zulu from the seconds since midnight.

Parameters:
second  seconds since midnight (0.0-86400.0)
tz  timezone (default to Greenwich mean)

Zulu::Zulu const Zulu &    z [inline]
 

Copy constructor.


Member Function Documentation

int Zulu::addTime time_t    dt [inline]
 

Advance the time, with 24 hour clock rollover.

Parameters:
dt  the number of seconds to add.
Returns:
the number days added or subtracted

Reimplemented in DateZulu, and SimDate.

virtual std::string Zulu::asString   const [inline, virtual]
 

Return the time as a string in the form "HH:MM::SSz".

Reimplemented in DateZulu, and SimDate.

void Zulu::convert struct tm *    tm,
bool    local = false
const
 

Extract time from a C tm structure.

Parameters:
tm  a time structure returned by gmtime() and localtime()
local  if true, tm represents the local time (not zulu).

Reimplemented in DateZulu.

std::string Zulu::formatString const char *    format,
bool    local = false
const
 

Format the time as a string.

Parameters:
format  a format string: see the standard C function strftime() for details.
local  if true, format the local time (not zulu).

Reimplemented in DateZulu.

int Zulu::getHour bool    local = false const [inline]
 

Get the hour.

Parameters:
local  adjust the result to reflect the timezone.

int Zulu::getMinute   const [inline]
 

Get the minute.

int Zulu::getSecond   const [inline]
 

Get the second.

time_t Zulu::getTime bool    local = false const [inline]
 

Get the curret time in seconds since midnight.

Parameters:
local  adjust the result to reflect the timezone.

int Zulu::getTZ   const [inline]
 

Get the timezone.

const Zulu& Zulu::operator= const Zulu &    z [inline]
 

Copy operator.

bool Zulu::overflow   const [inline]
 

Test if the time accumulator exceeds 24 hours.

int Zulu::reduce  
 

Wrap time to 24 hour period.

Reduces the seconds since midnight to the range 0-86400.

Returns:
the number of days subtracted to bring the time into range.

int Zulu::rollover   [inline]
 

Adjust the time to fit into the range 0-86400.

Returns:
the number of days added or subtracted.

int Zulu::setTime time_t    t,
bool    local = false
[inline]
 

Set the time.

Parameters:
t  the number of seconds since midnight.
local  if true, t represents the local time (not zulu).

void Zulu::setTZ int    tz [inline]
 

Set the timezone (only effects the local time).

Parameters:
tz  timezone (hour offset from Greenwich mean)

virtual std::string Zulu::typeString   const [inline, virtual]
 

Return a string representation of the type.

Reimplemented in DateZulu, and SimDate.


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]