mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4117 Improve time step names for Grid Cross plot categorisation
This commit is contained in:
@@ -338,3 +338,58 @@ QString RiaQDateTimeTools::toStringUsingApplicationLocale(const QDateTime& dt, c
|
||||
|
||||
return defaultApplicationLocale.toString(dt, format);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaQDateTimeTools::createTimeFormatStringFromDates(const std::vector<QDateTime>& dates)
|
||||
{
|
||||
bool hasHoursAndMinutesInTimesteps = false;
|
||||
bool hasSecondsInTimesteps = false;
|
||||
bool hasMillisecondsInTimesteps = false;
|
||||
|
||||
for (size_t i = 0; i < dates.size(); i++)
|
||||
{
|
||||
if (dates[i].time().msec() != 0.0)
|
||||
{
|
||||
hasMillisecondsInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
break;
|
||||
}
|
||||
else if (dates[i].time().second() != 0.0)
|
||||
{
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
}
|
||||
else if (dates[i].time().hour() != 0.0 || dates[i].time().minute() != 0.0)
|
||||
{
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
}
|
||||
}
|
||||
|
||||
QString formatString = dateFormatString();
|
||||
if (hasHoursAndMinutesInTimesteps)
|
||||
{
|
||||
formatString += " - hh:mm";
|
||||
if (hasSecondsInTimesteps)
|
||||
{
|
||||
formatString += ":ss";
|
||||
if (hasMillisecondsInTimesteps)
|
||||
{
|
||||
formatString += ".zzz";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return formatString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaQDateTimeTools::dateFormatString()
|
||||
{
|
||||
return "dd.MMM yyyy";
|
||||
}
|
||||
Reference in New Issue
Block a user