Export static function to check month name validity

This commit is contained in:
Joakim Hove
2020-11-26 19:55:45 +01:00
parent b6717fd685
commit 678edf4497
3 changed files with 10 additions and 0 deletions

View File

@@ -78,6 +78,7 @@ namespace Opm {
static std::time_t mkdate(int year, int month, int day);
static std::time_t mkdatetime(int year, int month, int day, int hour, int minute, int second);
static const std::map<std::string, int>& eclipseMonthIndices();
static bool valid_month(const std::string& month_name);
template<class Serializer>
void serializeOp(Serializer& serializer)

View File

@@ -246,6 +246,11 @@ struct TimeMapContext {
}
bool TimeMap::valid_month(const std::string& month_name) {
return (month_indices.count(month_name) != 0);
}
std::time_t TimeMap::timeFromEclipse(const DeckRecord &dateRecord) {
const auto &dayItem = dateRecord.getItem(0);
const auto &monthItem = dateRecord.getItem(1);

View File

@@ -815,4 +815,8 @@ TSTEP
BOOST_CHECK_NO_THROW( Opm::TimeMap(deck2, restart) );
BOOST_CHECK_NO_THROW( Opm::TimeMap(deck3, restart) );
BOOST_CHECK_THROW( Opm::TimeMap(deck4, restart) , std::exception);
BOOST_CHECK(Opm::TimeMap::valid_month("MAR"));
BOOST_CHECK(!Opm::TimeMap::valid_month("Tulleogtøys"));
}