Add conversion from scenario_time to std::string.

This commit is contained in:
Kamil Lewan
2018-07-22 16:46:54 +02:00
parent 9c5e80ceeb
commit ed359d3b4e
3 changed files with 11 additions and 5 deletions

View File

@@ -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 );
};
//---------------------------------------------------------------------------

View File

@@ -9,6 +9,8 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <string>
#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

View File

@@ -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)";
}