mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05: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";
|
||||
}
|
||||
@@ -101,6 +101,9 @@ public:
|
||||
// settings on local machine. Required for stable regression testing.
|
||||
static QString toStringUsingApplicationLocale(const QDateTime& dt, const QString& format);
|
||||
|
||||
static QString createTimeFormatStringFromDates(const std::vector<QDateTime>& dates);
|
||||
static QString dateFormatString();
|
||||
|
||||
private:
|
||||
static quint64 secondsInDay();
|
||||
static quint64 secondsInYear();
|
||||
|
||||
Reference in New Issue
Block a user