diff --git a/simulationtime.cpp b/simulationtime.cpp index 69ec910e..6ec42d08 100644 --- a/simulationtime.cpp +++ b/simulationtime.cpp @@ -194,4 +194,10 @@ scenario_time::julian_day() const { return JD; } +scenario_time::operator std::string(){ + + return to_string( m_time.wHour ) + ":" + + ( m_time.wMinute < 10 ? "0" : "" ) + to_string( m_time.wMinute ) + ":" + + ( m_time.wSecond < 10 ? "0" : "" ) + to_string( m_time.wSecond ); +}; //--------------------------------------------------------------------------- diff --git a/simulationtime.h b/simulationtime.h index 695a24cc..be5bdb86 100644 --- a/simulationtime.h +++ b/simulationtime.h @@ -9,6 +9,8 @@ http://mozilla.org/MPL/2.0/. #pragma once +#include + #include "winheaders.h" // wrapper for scenario time @@ -47,6 +49,8 @@ public: zone_bias() const { return m_timezonebias; } + /** Returns std::string in format: `"mm:ss"`. */ + operator std::string(); private: // calculates day and month from given day of year void diff --git a/uilayer.cpp b/uilayer.cpp index 71b1cd86..fc2442f3 100644 --- a/uilayer.cpp +++ b/uilayer.cpp @@ -279,12 +279,8 @@ ui_layer::update() { case( GLFW_KEY_F1 ) : { // f1, default mode: current time and timetable excerpt - auto const &time = simulation::Time.data(); uitextline1 = - "Time: " - + to_string( time.wHour ) + ":" - + ( time.wMinute < 10 ? "0" : "" ) + to_string( time.wMinute ) + ":" - + ( time.wSecond < 10 ? "0" : "" ) + to_string( time.wSecond ); + "Time: " + std::string( simulation::Time ); if( Global.iPause ) { uitextline1 += " (paused)"; }