next up previous contents
Next: Time Interval Handling Up: Some Functions and Methods Previous: Using Sequence Masks   Contents

Time Object Handling

There are two new base classes defined for qdos, Time and TimeInterval. These are used for the QdTime and QdTimeInterval classes in the same way that double is the base class for QdRScalar. Any method defined for Time is also available to a QdTime object.

A QDOS Time object is a representation of a time. A Time can either be treated as a date, i.e. a specific time instant in some date system (eg: ``14-Jun-1999 12:30:51.123'') or as a period of time (eg: 4503.237 seconds). Knowledge of the internal represention of date/time used by Time is usually not required. The representation is the class Time::TRep, which is a double representing seconds (for time periods) or seconds from J2000.0 (Jan 1, 12:00GMT). You may apply basic mathematical operations (+,-,*,/) to time objects, e.g. t1 += Seconds(90.0) to add 90 seconds to t1. Also, you may use following QDOS functions:

$\bullet$
Time Time( string& iso_time ) e.g.
Time t1("02-Jan-2000 12:00:00.000") to create a time object from an ISO string.
$\bullet$
Time Time(int year, int month, int day, double hour=0.0,
double min=0.0, double sec=0.0 ) e.g.
Time t1(2000,1,2,12.0) to create from a month/date representation. This is equivalent to Time t1(2000,1,2,12.0, 0.0, 0.0), but the default argument values ensure that it is only necessary to specify down to the last non-zero argument value.
$\bullet$
Days(int days),Hours(int hours),Minutes(int minutes),
Seconds(double seconds), mSeconds(int msecs)
e.g. t1 = t0(2000,1,1) + Days(1) + Hours(12) + Seconds(30.005)
to add days, hours, minutes, seconds (and milliseconds are added through the fractional part of seconds). Time units roll over, so that
t1 += Minutes(1) + Seconds(1.5) is equivalent to t1 += Seconds(61.5)
$\bullet$
Time& set_ydoy(int year, int doy, double hour=0.0, double min=0.0,
double sec=0.0 ),
e.g. t1.set_ydoy(2000,2,12) to set t1 from year and day-of-year.
$\bullet$
Time& set_ymd(int year, int month, int day, double hour=0.0,
double min=0.0, double sec=0.0 )
e.g. t1.set_ymd(2000,1,2,12) to set t1 from year, month and day.
$\bullet$
double day_of_year(void ), e.g. doy = t1.day_of_year() will return 1.5.
$\bullet$
void display(), e.g. t1.display() will display current value of t1 on stdout.
$\bullet$
string iso_srep(void ), e.g. tstr = t1.iso_rep() will return ISO string.
$\bullet$
void split_dhms(int& d, int& h, int& m, double& s ),
e.g. t1.split_dhms(d,h,m,s) will return a duration as days, hours, minutes, seconds.
$\bullet$
void split_ydoy(int& year, int& doy, int& hour, int& min,
double& sec )
e.g. t1.split_ydoy(year,doy,hour) will return year, doy, hour etc.
$\bullet$
void split_ymd(int& year, int& month, int& day, int& hour,
int& min, double& sec ),
e.g. t1.split_ymd(year,month,day,hour) will return year, month, day, hour of t1.


next up previous contents
Next: Time Interval Handling Up: Some Functions and Methods Previous: Using Sequence Masks   Contents
Anthony Allen 2005-11-07