Commit 4a3140d3 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

BUG: correct date formatting when time components have only one digit

parent ba383d3b
Pipeline #7391 canceled with stages
in 4 minutes and 9 seconds
......@@ -416,13 +416,23 @@ void CosmoImageMetadataInterface::ParseGdal(ImageMetadata & imd)
int hour = static_cast<int> (total_seconds/3600.0);
int minutes = static_cast<int> ((total_seconds-hour*3600)/60.0);
double seconds = total_seconds - hour*3600 - minutes*60;
std::string first_line_time = reference_UTC + "T" + std::to_string(hour) + ":" + std::to_string(minutes) + ":" + std::to_string(seconds);
// Helper function to convert to a two digit string.
auto formatTimeInt = [](int i) { return (i < 10 ? "0" + std::to_string(i)
: std::to_string(i) );};
auto formatTimeDouble = [](double d) { return (d < 10 ? "0" + std::to_string(d)
: std::to_string(d) );};
std::string first_line_time = reference_UTC + "T" + formatTimeInt(hour) + ":" + formatTimeInt(minutes) + ":" + formatTimeDouble(seconds);
total_seconds = std::stod(metadataBands[0]["S01_SBI_Zero_Doppler_Azimuth_Last_Time"]);
hour = static_cast<int> (total_seconds/3600.0);
minutes = static_cast<int> ((total_seconds-hour*3600)/60.0);
seconds = total_seconds - hour*3600 - minutes*60;
std::string last_line_time = reference_UTC + "T" + std::to_string(hour) + ":" + std::to_string(minutes) + ":" + std::to_string(seconds);
std::string last_line_time = reference_UTC + "T" + formatTimeInt(hour) + ":" + formatTimeInt(minutes) + ":" + formatTimeDouble(seconds);
MetaData::Time startTime = Utils::LexicalCast<MetaData::Time,std::string>(first_line_time, std::string("T"));
MetaData::Time stoptTime = Utils::LexicalCast<MetaData::Time,std::string>(last_line_time, std::string("T"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment