SilverLining: SilverLining::LocalTime Class Reference

SilverLining 2.36

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# 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:
[legend]
Collaboration diagram for SilverLining::LocalTime:
[legend]

List of all members.

## 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

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_API SilverLining::LocalTime::AddSeconds | ( | long | seconds | ) |

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

int SILVERLINING_API SilverLining::LocalTime::GetDay | ( |  | ) | const`[inline]`

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

See also:
  SetDay()

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:

  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_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:

  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_API SilverLining::LocalTime::GetHour | ( |  | ) | const`[inline]`

Retrieves the hour of day (0-23).

See also:
  SetHour()

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:

  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_API SilverLining::LocalTime::GetMinutes | ( |  | ) | const`[inline]`

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

See also:
  SetMinutes()

int SILVERLINING_API SilverLining::LocalTime::GetMonth | ( |  | ) | const`[inline]`

Retrieves the calendar month (1-12).

See also:
  SetMonth()

bool SILVERLINING_API SilverLining::LocalTime::GetObservingDaylightSavingsTime | ( |  | ) | const`[inline]`

Retrieves if daylight savings time is observed in the simulation.

See also:
  SetObservingDaylightSavingsTime()

double SILVERLINING_API SilverLining::LocalTime::GetSeconds | ( |  | ) | const`[inline]`

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

See also:
  SetSeconds()

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

int SILVERLINING_API SilverLining::LocalTime::GetYear | ( |  | ) | const`[inline]`

Retrieves the Gregorian calendar year.

See also:
  SetYear()

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

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

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

  time | Seconds elapsed since midnight, January 1, 1970 UTC.

void SILVERLINING_API SilverLining::LocalTime::SetFromSystemTime | ( |  | ) |

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

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

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

  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_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:

- /home/fkane/sl/trunk/Public Headers/LocalTime.h