time.h File Reference

Classes and functions dealing with the semantics of time. More...

Go to the source code of this file.

Classes

class  Time
struct  ExpandedDateTime
 ExpandedDateTime: Struct with fields for Year, Month, Day, Hour, etc. More...

Defines

#define HoursToTime(h)   ( ((double)h) / 24.0 )
 Convert hours h to time (double).

Functions

double EdtToTime (ExpandedDateTime *pd)
 Convert ExpandedDateTime struct to date+time represented as a double.
void TimeToEdt (ExpandedDateTime *p, double time)
 Expand date+time represented as a double to ExandedDateTime struct.
double GetCurrentTime ()
 Returns a double representing the current date+time.
void PrintTime (double d, int full=0)
 Print time.
double StrToDate (char *s)
 Convert string with date in format YYYYMMDDHHMMSS to date in double.
void TestTime (char *timeStr)
 For test purposes, force current time to timeStr in YYYYMMDDHHMMSS format.
DataTimeAct (Context *p)


Detailed Description

Classes and functions dealing with the semantics of time.

Author:
Bryan Jacobson, 2006.

Define Documentation

#define HoursToTime  )     ( ((double)h) / 24.0 )
 

Convert hours h to time (double).


Function Documentation

double EdtToTime ExpandedDateTime p  ) 
 

Convert ExpandedDateTime struct to date+time represented as a double.

Convert ExpandedDateTime struct to date+time represented as a double. See TimeToEdt() for explanation of date+time as a double. The value in p->mLeapFlag is ignored. Values are not checked to confirm they are in their appropriate ranges. TODO: This should be a method of EDT.

double GetCurrentTime  ) 
 

Returns a double representing the current date+time.

Returns a double representing the current date+time. Note: If a value is specified by TestTime() it will overide local current time.

void PrintTime double  d,
int  full = 0
 

Print time.

double StrToDate char *  s  ) 
 

Convert string with date in format YYYYMMDDHHMMSS to date in double.

void TestTime char *  timeStr  ) 
 

For test purposes, force current time to timeStr in YYYYMMDDHHMMSS format.

For test purposes, force current time to time specificied by timeStr in YYYYMMDDHHMMSS format. This is accomplished by forcing GetCurrentTime() to return the time specified rather than the current time.

Data* TimeAct Context p  ) 
 

void TimeToEdt ExpandedDateTime p,
double  time
 

Expand date+time represented as a double to ExandedDateTime struct.

Expand date+time represented as a double to ExpandedDateTime struct. When date+time is represented as a double, the integer portion (which can be negative) represents the number of days since Jan 1, 1900. The fractional part of the double represents the fraction of the 24 hour day that has elapsed. Example: 0.5 == 12:00 noon, 0.25 = 6:00 AM.

Note: This conversion takes into account the fairly complicated rule for leap days (leap year if divisible by 4, but not 100, unless also divisible by 400). So 2000 is a leap year, while 1900 and 1800 were not.

Limitations:

  • No accomodation is made for leap seconds.
  • Currently, no accomodation is made for timezones.
  • This leap year implementation represents a Gregorian calendar. Note that Great Brittain was on the Julian calendar until September 1752, when Great Brittain dropped 11 days to align with the Gregorian calendar. The Gregorian calendar was introduced in Italy, Poland, Portugal and Spain in 1582, by dropping 10 days in October. Prior to 1582, the Julian calendar was in use. No accomodation is made for Julian calendar dates. The only negative consequence of this is that calculcation of number of *days* between events can be off by a few days if one of the dates is Julian (Battle of Hastings Oct 14, 1066), and the other is date is Gregorian (first Moon landing July 20, 1969).

TODO: This should be a method of EDT.


Generated on Sun Oct 8 09:32:10 2006 for gabbie by  doxygen 1.4.6