Skip to content

Commit c552ccc

Browse files
committed
Logging: Cast the stringified timestamp to seconds to restore behavior prior to lib{fmt} upgrade
1 parent c959742 commit c552ccc

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

core/include/utility/Timing.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Timing
1313
{
1414

1515
// Returns the current time like: 2012-05-06_21:47:59
16-
std::string CurrentDateTime();
16+
std::string CurrentDateTimeSeconds();
1717

1818
// Returns the DateTime difference between two DateTimes
1919
std::string DateTimePassed( std::chrono::duration<scalar> dt );

core/src/Spirit/Log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ try
101101
Log.file_tag = file_tag;
102102

103103
if( file_tag == std::string( "<time>" ) )
104-
Log.file_name = "Log_" + Utility::Timing::CurrentDateTime() + ".txt";
104+
Log.file_name = "Log_" + Utility::Timing::CurrentDateTimeSeconds() + ".txt";
105105
else if( file_tag == std::string( "" ) )
106106
Log.file_name = "Log.txt";
107107
else
@@ -208,4 +208,4 @@ catch( ... )
208208
{
209209
spirit_handle_exception_api( -1, -1 );
210210
return 0;
211-
}
211+
}

core/src/Spirit/Simulation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void run_method( Engine::Method & method, bool singleshot, Simulation_Run_Info *
4040
if( singleshot )
4141
{
4242
//---- Start timings
43-
method.starttime = Utility::Timing::CurrentDateTime();
43+
method.starttime = Utility::Timing::CurrentDateTimeSeconds();
4444
method.t_start = std::chrono::system_clock::now();
4545
method.t_last = std::chrono::system_clock::now();
4646
method.iteration = 0;

core/src/engine/Method.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ Method::Method( std::shared_ptr<Data::Parameters_Method> parameters, int idx_img
4545
for( std::uint8_t i = 0; i < 7; ++i )
4646
this->t_iterations.push_back( std::chrono::system_clock::now() );
4747
this->ips = 0;
48-
this->starttime = Timing::CurrentDateTime();
48+
this->starttime = Timing::CurrentDateTimeSeconds();
4949
}
5050

5151
void Method::Iterate()
5252
{
5353
//---- Start timings
54-
this->starttime = Timing::CurrentDateTime();
54+
this->starttime = Timing::CurrentDateTimeSeconds();
5555
this->t_start = std::chrono::system_clock::now();
5656
auto t_current = std::chrono::system_clock::now();
5757
this->t_last = std::chrono::system_clock::now();

core/src/io/configparser/Logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ try
2626
Log.output_folder = output_folder;
2727

2828
if( file_tag == "<time>" )
29-
Log.file_name = "Log_" + Utility::Timing::CurrentDateTime() + ".txt";
29+
Log.file_name = "Log_" + Utility::Timing::CurrentDateTimeSeconds() + ".txt";
3030
else if( !file_tag.empty() )
3131
Log.file_name = "Log_" + file_tag + ".txt";
3232
else

core/src/utility/Logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::string IndexToString( int idx )
2828
LoggingHandler::LoggingHandler()
2929
{
3030
if( file_tag == "<time>" )
31-
file_name = fmt::format( "Log_{}.txt", Utility::Timing::CurrentDateTime() );
31+
file_name = fmt::format( "Log_{}.txt", Utility::Timing::CurrentDateTimeSeconds() );
3232
else if( file_tag.empty() )
3333
file_name = "Log.txt";
3434
else

core/src/utility/Timing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ namespace Timing
1515
using std::chrono::duration;
1616
using std::chrono::system_clock;
1717

18-
std::string CurrentDateTime()
18+
std::string CurrentDateTimeSeconds()
1919
{
2020
// Get timepoint
21-
system_clock::time_point now = system_clock::now();
21+
system_clock::time_point now = std::chrono::time_point_cast<std::chrono::seconds>( system_clock::now() );
2222
// Return string from timepoint
2323
return fmt::format( "{:%Y-%m-%d_%H-%M-%S}", now );
2424
}

0 commit comments

Comments
 (0)