SilverLining
Public Member Functions | List of all members
SilverLining::LocalTime Class Reference

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

#include <LocalTime.h>

Inheritance diagram for SilverLining::LocalTime:
Inheritance graph
[legend]
Collaboration diagram for SilverLining::LocalTime:
Collaboration graph
[legend]

Public Member Functions

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

Constructor & Destructor Documentation

◆ LocalTime()

SilverLining::LocalTime::LocalTime ( )

Default constructor.

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

◆ ~LocalTime()

virtual SilverLining::LocalTime::~LocalTime ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ AddSeconds()

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

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

◆ GetDay()

int SILVERLINING_API SilverLining::LocalTime::GetDay ( ) const
inline

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

See also
SetDay()

◆ GetEpoch1990Days()

double SILVERLINING_API 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
terrestrialTimeSpecifying 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.

◆ GetEpoch2000Centuries()

double SILVERLINING_API 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
terrestrialTimeSpecifying 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.

◆ GetHour()

int SILVERLINING_API SilverLining::LocalTime::GetHour ( ) const
inline

Retrieves the hour of day (0-23).

See also
SetHour()

◆ GetJulianDate()

double SILVERLINING_API 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
terrestrialTimeSpecifying 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.

◆ GetMinutes()

int SILVERLINING_API SilverLining::LocalTime::GetMinutes ( ) const
inline

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

See also
SetMinutes()

◆ GetMonth()

int SILVERLINING_API SilverLining::LocalTime::GetMonth ( ) const
inline

Retrieves the calendar month (1-12).

See also
SetMonth()

◆ GetObservingDaylightSavingsTime()

bool SILVERLINING_API SilverLining::LocalTime::GetObservingDaylightSavingsTime ( ) const
inline

Retrieves if daylight savings time is observed in the simulation.

See also
SetObservingDaylightSavingsTime()

◆ GetSeconds()

double SILVERLINING_API SilverLining::LocalTime::GetSeconds ( ) const
inline

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

See also
SetSeconds()

◆ GetTimeZone()

double SILVERLINING_API SilverLining::LocalTime::GetTimeZone ( ) const
inline

Retrieves the currently simulated time zone.

Returns
The hour offset from GMT, ignoring daylight savings time.
See also
SetTimeZone()

◆ GetYear()

int SILVERLINING_API SilverLining::LocalTime::GetYear ( ) const
inline

Retrieves the Gregorian calendar year.

See also
SetYear()

◆ Serialize()

bool SILVERLINING_API SilverLining::LocalTime::Serialize ( std::ostream &  stream)

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

◆ SetDay()

void SILVERLINING_API SilverLining::LocalTime::SetDay ( int  day)
inline

Sets the day of the month to simulate.

Parameters
dayThe day of month, ranging from 1-31.
See also
GetDay()

◆ SetFromEpochSeconds()

void SILVERLINING_API 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
timeSeconds elapsed since midnight, January 1, 1970 UTC.

◆ SetFromSystemTime()

void SILVERLINING_API SilverLining::LocalTime::SetFromSystemTime ( )

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

◆ SetHour()

void SILVERLINING_API SilverLining::LocalTime::SetHour ( int  hour)
inline

Sets the hour of day to simulate.

Parameters
hourThe hour of day, ranging from 0-23 (0=midnight, 12=noon, 23=11PM)
See also
GetHour()

◆ SetMinutes()

void SILVERLINING_API SilverLining::LocalTime::SetMinutes ( int  minutes)
inline

Sets the minute of the hour to simulate.

Parameters
minutesMinutes from 0-59
See also
GetMinutes()

◆ SetMonth()

void SILVERLINING_API SilverLining::LocalTime::SetMonth ( int  month)
inline

Sets the calendar month to simulate.

Parameters
monthThe month to simulate, ranging from 1 (January) to 12 (December).
See also
GetMonth();

◆ SetObservingDaylightSavingsTime()

void SILVERLINING_API 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()

◆ SetSeconds()

void SILVERLINING_API SilverLining::LocalTime::SetSeconds ( double  seconds)
inline

Sets the second of the minute to simulate.

Parameters
secondsSeconds from 0-59.
See also
GetSeconds()

◆ SetTimeZone()

void SILVERLINING_API 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, unless you choose to specify all times in GMT consistently instead of using local time.

Parameters
zoneHour 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()

◆ SetYear()

void SILVERLINING_API 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: