SilverLining::LocalTime Class Reference

A class to represent the simulated local time, time zone, and daylight savings time observation. More...

#include <LocalTime.h>

List of all members.

Public Member Functions

 LocalTime ()
 Default constructor.
virtual ~LocalTime ()
 Destructor.
void SetFromEpochSeconds (time_t time)
 Populates the LocalTime class based on epoch seconds (ie, as returned from time(NULL) ).
void SetYear (int year)
 Set the calendar year to simulate.
int GetYear () const
 Retrieves the Gregorian calendar year.
void SetMonth (int month)
 Sets the calendar month to simulate.
int GetMonth () const
 Retrieves the calendar month (1-12).
void SetDay (int day)
 Sets the day of the month to simulate.
int GetDay () const
 Retrieves the day of the month (1-31).
void SetHour (int hour)
 Sets the hour of day to simulate.
int GetHour () const
 Retrieves the hour of day (0-23).
void SetMinutes (int minutes)
 Sets the minute of the hour to simulate.
int GetMinutes () const
 Retrieves the minute of the hour (0-59).
void SetSeconds (double seconds)
 Sets the second of the minute to simulate.
double GetSeconds () const
 Retrieves the second of the minute (0-59).
void SetObservingDaylightSavingsTime (bool inDST)
 Sets if Daylight Savings Time is currently observed in the simulation.
bool GetObservingDaylightSavingsTime () const
 Retrieves if daylight savings time is observed in the simulation.
void SetTimeZone (double zone)
 Specifies the time zone being simulated.
double GetTimeZone () const
 Retrieves the currently simulated time zone.
double GetJulianDate (bool terrestrialTime) const
 Retrieves the Julian Date that this LocalTime object represents.
double GetEpoch2000Centuries (bool terrestrialTime) const
 Obtains centuries and fraction since January 1, 2000 represented by this object.
double GetEpoch1990Days (bool terrestrialTime) const
 Obtains days elapsed since January 1, 1990 represented by this object on the Julian calendar.
void SetFromSystemTime ()
 Populate the object based on the system's current local time settings.
void AddSeconds (long seconds)
 Add the given number of seconds to the time represented by this object.
bool Serialize (std::ostream &stream)
 Flattens this object and everything in it to a stream buffer.
bool Unserialize (std::istream &stream)
 Restores this object from the stream created using Serialize().

Detailed Description

A class to represent the simulated local time, time zone, and daylight savings time observation.

LocalTime objects are passed into AtmosphericConditions::SetTime() to change the simulated time of day. Be sure that your Location object represents a location consistent with the time zone you have specified as well.


Constructor & Destructor Documentation

SilverLining::LocalTime::LocalTime (  ) 

Default constructor.

Creates a local time with default settings (read from the SilverLining.config file if constructed after calling Atmosphere::Initialize()).

virtual SilverLining::LocalTime::~LocalTime (  )  [inline, virtual]

Destructor.


Member Function Documentation

void SilverLining::LocalTime::AddSeconds ( long  seconds  ) 

Add the given number of seconds to the time represented by this object.

int SilverLining::LocalTime::GetDay (  )  const [inline]

Retrieves the day of the month (1-31).

See also:
SetDay()
double SilverLining::LocalTime::GetEpoch1990Days ( bool  terrestrialTime  )  const

Obtains days elapsed since January 1, 1990 represented by this object on the Julian calendar.

Used for internal astronomical calculations. Since this number is smaller than that returned by GetJulianDate(), it is of higher precision.

Parameters:
terrestrialTime Specifying terrestrial time means you want atomic clock time, not corrected by leap seconds to account for slowing of the Earth's rotation, as opposed to GMT which does account for leap seconds.
Returns:
The fractional number of days elapsed since January 1, 1990.
double SilverLining::LocalTime::GetEpoch2000Centuries ( bool  terrestrialTime  )  const

Obtains centuries and fraction since January 1, 2000 represented by this object.

Used for internal astronomical calculations. Since this number is smaller than that returned by GetJulianDate(), it is of higher precision.

Parameters:
terrestrialTime Specifying terrestrial time means you want atomic clock time, not corrected by leap seconds to account for slowing of the Earth's rotation, as opposed to GMT which does account for leap seconds.
Returns:
The fractional number of centuries elapsed since January 1, 2000.
int SilverLining::LocalTime::GetHour (  )  const [inline]

Retrieves the hour of day (0-23).

See also:
SetHour()
double SilverLining::LocalTime::GetJulianDate ( bool  terrestrialTime  )  const

Retrieves the Julian Date that this LocalTime object represents.

Julian Dates are used for astronomical calculations (such as our own ephemeris model) and represent days and fractions since noon Universal Time on January 1, 4713 BCE on the Julian calendar. Note that due to precision limitations of 64-bit doubles, the resolution of the date returned may be as low as within 8 hours.

Parameters:
terrestrialTime Specifying terrestrial time means you want atomic clock time, not corrected by leap seconds to account for slowing of the Earth's rotation, as opposed to GMT which does account for leap seconds.
Returns:
the Julian date that this object represents.
int SilverLining::LocalTime::GetMinutes (  )  const [inline]

Retrieves the minute of the hour (0-59).

See also:
SetMinutes()
int SilverLining::LocalTime::GetMonth (  )  const [inline]

Retrieves the calendar month (1-12).

See also:
SetMonth()
bool SilverLining::LocalTime::GetObservingDaylightSavingsTime (  )  const [inline]

Retrieves if daylight savings time is observed in the simulation.

See also:
SetObservingDaylightSavingsTime()
double SilverLining::LocalTime::GetSeconds (  )  const [inline]

Retrieves the second of the minute (0-59).

See also:
SetSeconds()
double SilverLining::LocalTime::GetTimeZone (  )  const [inline]

Retrieves the currently simulated time zone.

Returns:
The hour offset from GMT, ignoring daylight savings time.
See also:
SetTimeZone()
int SilverLining::LocalTime::GetYear (  )  const [inline]

Retrieves the Gregorian calendar year.

See also:
SetYear()
bool SilverLining::LocalTime::Serialize ( std::ostream &  stream  ) 

Flattens this object and everything in it to a stream buffer.

void SilverLining::LocalTime::SetDay ( int  day  )  [inline]

Sets the day of the month to simulate.

Parameters:
day The day of month, ranging from 1-31.
See also:
GetDay()
void SilverLining::LocalTime::SetFromEpochSeconds ( time_t  time  ) 

Populates the LocalTime class based on epoch seconds (ie, as returned from time(NULL) ).

Internally, it calls gmtime() on the value passed in, and populates the class based on the its results. The time zone will be set to GMT.

Parameters:
time Seconds elapsed since midnight, January 1, 1970 UTC.
void SilverLining::LocalTime::SetFromSystemTime (  ) 

Populate the object based on the system's current local time settings.

void SilverLining::LocalTime::SetHour ( int  hour  )  [inline]

Sets the hour of day to simulate.

Parameters:
hour The hour of day, ranging from 0-23 (0=midnight, 12=noon, 23=11PM)
See also:
GetHour()
void SilverLining::LocalTime::SetMinutes ( int  minutes  )  [inline]

Sets the minute of the hour to simulate.

Parameters:
minutes Minutes from 0-59
See also:
GetMinutes()
void SilverLining::LocalTime::SetMonth ( int  month  )  [inline]

Sets the calendar month to simulate.

Parameters:
month The month to simulate, ranging from 1 (January) to 12 (December).
See also:
GetMonth();
void SilverLining::LocalTime::SetObservingDaylightSavingsTime ( bool  inDST  )  [inline]

Sets if Daylight Savings Time is currently observed in the simulation.

Not required if using SetFromEpochSeconds(), but must be set otherwise.

See also:
GetObservingDaylightSavingsTime()
void SilverLining::LocalTime::SetSeconds ( double  seconds  )  [inline]

Sets the second of the minute to simulate.

Parameters:
seconds Seconds from 0-59.
See also:
GetSeconds()
void SilverLining::LocalTime::SetTimeZone ( double  zone  )  [inline]

Specifies the time zone being simulated.

This is an hour offset from GMT, use the TimeZones enumerated type as a convenient way to specify the hour offset for a known time zone. Be sure that this time zone is consistent with the Location you specify.

Parameters:
zone Hour offset from GMT, ignoring daylight savings time. ie, PST is -8. Use the TimeZones enumeration to obtain the hour offset for specific time zones.
See also:
GetTimeZone()
void SilverLining::LocalTime::SetYear ( int  year  )  [inline]

Set the calendar year to simulate.

SilverLining can only handle Gregorian calendar years, which means that years before 1582 will not be accurately simulated.

See also:
GetYear()

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2