#14111 Preserve time-of-day in exported DATES keyword

The Event Timeline stores event timestamps with full time-of-day precision, but the exported SCHEDULE deck only emitted DAY/MONTH/YEAR in the DATES keyword, dropping any sub-day precision the user had set.

Emit the optional TIME field (HH:MM:SS[.SSS]) in datesKeyword() whenever the timestamp is non-midnight, formatting with millisecond precision when present. Date-only events keep their previous DAY/MONTH/YEAR-only output. The first-date comment in the schedule generator mirrors the same time so it stays consistent with the keyword.
This commit is contained in:
Kristian Bendiksen committed 2026-06-05 16:21:01 +02:00
1 parent 8b65c313f8
commit cbae501a13
4 files changed
+78 -2

No files matched your search

@@ -754,6 +754,16 @@ Opm::DeckKeyword datesKeyword( const QDateTime& date )
items.push_back( RifOpmDeckTools::item( D::MONTH::itemName, month.toStdString() ) );
items.push_back( RifOpmDeckTools::item( D::YEAR::itemName, year ) );
// Emit the optional TIME field (HH:MM:SS[.SSS], default 00:00:00) only when the timestamp carries a
// non-midnight time, so date-only events keep their plain DAY/MONTH/YEAR output. QDateTime resolves
// to milliseconds, which is the finest precision we can preserve here.
const QTime time = date.time();
if ( time.isValid() && ( time.hour() != 0 || time.minute() != 0 || time.second() != 0 || time.msec() != 0 ) )
{
const QString timeStr = ( time.msec() != 0 ) ? time.toString( "HH:mm:ss.zzz" ) : time.toString( "HH:mm:ss" );
items.push_back( RifOpmDeckTools::item( D::TIME::itemName, timeStr.toStdString() ) );
}
Opm::DeckKeyword kw{ D() };
kw.addRecord( Opm::DeckRecord{ std::move( items ) } );
return kw;