mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve date parser to work better with some GeoMech time step names
This commit is contained in:
parent
dc4d4e0fa2
commit
df5ba4c0d1
@ -47,11 +47,17 @@ QDateTime RiaDateStringParser::parseDateString( const std::string& dateString )
|
||||
tryParseDayFirst( dateString, year, month, day ) ||
|
||||
tryParseMonthFirst( dateString, year, month, day );
|
||||
}
|
||||
else if ( !RiaStdStringTools::containsAlphabetic( dateString ) )
|
||||
if ( !parsedOk )
|
||||
{
|
||||
parsedOk = tryParseYearFirstNoSeparators( dateString, year, month, day ) ||
|
||||
tryParseDayFirstNoSeparators( dateString, year, month, day ) ||
|
||||
tryParseMonthFirstNoSeparators( dateString, year, month, day );
|
||||
auto firstNumerical = dateString.find_first_of( "0123456789" );
|
||||
if ( firstNumerical != std::string::npos )
|
||||
{
|
||||
std::string subString = dateString.substr( firstNumerical );
|
||||
|
||||
parsedOk = tryParseYearFirstNoSeparators( subString, year, month, day ) ||
|
||||
tryParseDayFirstNoSeparators( subString, year, month, day ) ||
|
||||
tryParseMonthFirstNoSeparators( subString, year, month, day );
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime dt;
|
||||
|
@ -111,7 +111,7 @@ TEST( RiaDateStringParserTest, ParseWithoutSeparators )
|
||||
may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
|
||||
feb5thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
|
||||
|
||||
std::vector<std::string> may2ndStrings = {"20110502", "02052011"};
|
||||
std::vector<std::string> may2ndStrings = {"20110502", "02052011", "Date_20110502"};
|
||||
for ( auto may2ndString : may2ndStrings )
|
||||
{
|
||||
QDateTime parsedDate = RiaDateStringParser::parseDateString( may2ndString );
|
||||
|
Loading…
Reference in New Issue
Block a user