mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4017 Add function used to determine date format from text string
This commit is contained in:
@@ -288,6 +288,77 @@ void RicPasteAsciiDataToSummaryPlotFeatureUi::createNewPlot()
|
||||
m_createNewPlot = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi::dateFormatFromString(const QString& dateString)
|
||||
{
|
||||
std::vector<int> indicesForDot;
|
||||
std::vector<int> indicesForSlash;
|
||||
std::vector<int> values;
|
||||
|
||||
{
|
||||
QStringList split = dateString.split(".", QString::SkipEmptyParts);
|
||||
if (split.size() == 3)
|
||||
{
|
||||
values.push_back(split.at(0).toInt());
|
||||
values.push_back(split.at(1).toInt());
|
||||
values.push_back(split.at(2).toInt());
|
||||
|
||||
if (values[0] > 31) return DATE_YYYYMMDD_DOT_SEPARATED;
|
||||
if (values[2] > 31) return DATE_DDMMYYYY_DOT_SEPARATED;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QStringList split = dateString.split("-", QString::SkipEmptyParts);
|
||||
if (split.size() == 3)
|
||||
{
|
||||
values.push_back(split.at(0).toInt());
|
||||
values.push_back(split.at(1).toInt());
|
||||
values.push_back(split.at(2).toInt());
|
||||
|
||||
if (values[0] > 31) return DATE_YYYYMMDD_DASH_SEPARATED;
|
||||
if (values[2] > 31) return DATE_DDMMYYYY_DASH_SEPARATED;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QStringList split = dateString.split("/", QString::SkipEmptyParts);
|
||||
if (split.size() == 3)
|
||||
{
|
||||
values.push_back(split.at(0).toInt());
|
||||
values.push_back(split.at(1).toInt());
|
||||
values.push_back(split.at(2).toInt());
|
||||
|
||||
if (split.at(0).size() == 2 && split.at(1).size() == 2 && split.at(2).size() == 2) return DATE_MMDDYY_SLASH_SEPARATED;
|
||||
|
||||
if (values[0] > 31)
|
||||
{
|
||||
return DATE_YYYYMMDD_SLASH_SEPARATED;
|
||||
}
|
||||
else if (values[2] > 31)
|
||||
{
|
||||
if (values[0] > 12)
|
||||
{
|
||||
return DATE_DDMMYYYY_SLASH_SEPARATED;
|
||||
}
|
||||
|
||||
if (values[1] > 12)
|
||||
{
|
||||
return DATE_MMDDYYYY_SLASH_SEPARATED;
|
||||
}
|
||||
|
||||
return DATE_DDMMYYYY_SLASH_SEPARATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DATE_DDMMYYYY_DOT_SEPARATED;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -133,6 +133,8 @@ public:
|
||||
const AsciiDataParseOptions parseOptions() const;
|
||||
void createNewPlot();
|
||||
|
||||
static DateFormat dateFormatFromString(const QString& dateString);
|
||||
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
|
||||
Reference in New Issue
Block a user