#1362 Support timesteps with higher resolution than seconds

This commit is contained in:
Bjørnar Grip Fjær
2017-04-06 12:22:27 +02:00
parent aebb1fb7bd
commit cb8b773f23
2 changed files with 25 additions and 2 deletions

View File

@@ -162,9 +162,12 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
CVF_ASSERT(reportDateTime.isValid());
double dayFraction = dayFractions[i];
int seconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0);
int milliseconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0 * 1000.0);
int seconds = milliseconds % 1000;
milliseconds -= seconds * 1000;
QTime time(0, 0);
time = time.addSecs(seconds);
time = time.addMSecs(milliseconds);
reportDateTime.setTime(time);

View File

@@ -579,19 +579,39 @@ QString RimEclipseCase::timeStepName(int frameIdx)
if (m_timeStepFormatString.isEmpty())
{
bool hasHoursAndMinutesInTimesteps = false;
bool hasSecondsInTimesteps = false;
bool hasMillisecondsInTimesteps = false;
for (size_t i = 0; i < timeStepDates.size(); i++)
{
if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
if (timeStepDates[i].time().msec() != 0.0)
{
hasMillisecondsInTimesteps = true;
hasSecondsInTimesteps = true;
hasHoursAndMinutesInTimesteps = true;
break;
}
else if (timeStepDates[i].time().second() != 0.0) {
hasHoursAndMinutesInTimesteps = true;
hasSecondsInTimesteps = true;
}
else if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
{
hasHoursAndMinutesInTimesteps = true;
}
}
m_timeStepFormatString = "dd.MMM yyyy";
if (hasHoursAndMinutesInTimesteps)
{
m_timeStepFormatString += " - hh:mm";
if (hasSecondsInTimesteps)
{
m_timeStepFormatString += ":ss";
if (hasMillisecondsInTimesteps)
{
m_timeStepFormatString += ".zzz";
}
}
}
}