SimApi Timer setTimeOfDay

From SIMboxWiki
Jump to navigation Jump to search



Icon attributes.pngstatic void SimApi::Timer::setTimeOfDay(const unsigned long secFromMidnight)

    Description

    Sets current simulation time of day in seconds

    Parameters

    secFromMidnight - number of seconds from midnight

    Remarks
    

Sets current simulation time of day in seconds. If GLOBAL_PROP_SMG_SHOW_TIME_IN_LOCAL set to true, the time will be converted from GMT to local time. If GLOBAL_ATT_IS_ALLOW_CHANGE_GRAPHIC_ENGINE_TIME_OF_DAY is set to true, graphics engine's time of day will be updated too, otherwise, it will be reset to the fixed time, defined in: GLOBAL_ATT_SMG_GRAPHIC_ENGINE_FIXED_HOURS, GLOBAL_ATT_SMG_GRAPHIC_ENGINE_FIXED_MINUTES and GLOBAL_ATT_SMG_GRAPHIC_ENGINE_FIXED_SECONDS.


    Code Sample
    

//assume we have an extension with one button that toggles between day
//and night in order to allow the trainee to train a mission in different day light.
//this function is called when the toggle day light button is clicked.
void ToggleDayLightExtension::OnToggleDayLight(bool i_isDay)
{
 //if we would like to change day light to night
 if(!i_isDay)
 {
 SimApi::Timer::setTimeOfDay(0); //midnight
 }else
 {
 //3600 is the number of seconds in an hour.12 * 3600 is the number of seconds since midnight.
 unsigned long noonTime = 12 * 3600;
 SimApi::Timer::setTimeOfDay(noonTime); //noon
 }
}


    Related Links

    Recommended: Simulation Time Overview