mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* #2082 Support custom date time format * Clang-format
This commit is contained in:
@@ -392,4 +392,80 @@ QString RiaQDateTimeTools::createTimeFormatStringFromDates(const std::vector<QDa
|
||||
QString RiaQDateTimeTools::dateFormatString()
|
||||
{
|
||||
return "dd.MMM yyyy";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RiaQDateTimeTools::supportedDateFormats()
|
||||
{
|
||||
std::vector<QString> dateFormats;
|
||||
|
||||
// See enum DateFormatComponents in header
|
||||
// The semi-colon separated components are:
|
||||
// DATE_FORMAT_YEAR, ..YEAR_MONTH, ..YEAR_MONTH_DAY
|
||||
dateFormats.push_back("yyyy;yyyy-MM;yyyy-MM-dd");
|
||||
dateFormats.push_back("yyyy;MMM yyyy;dd. MMM yyyy");
|
||||
dateFormats.push_back("yyyy;MMM yyyy;MMM dd. yyyy");
|
||||
dateFormats.push_back("yyyy;MM/yyyy;dd/MM/yyyy");
|
||||
dateFormats.push_back("yyyy;M/yyyy;d/M/yyyy");
|
||||
dateFormats.push_back("yyyy;M/yyyy;M/d/yyyy");
|
||||
dateFormats.push_back("yy;M/yy;d/M/yy");
|
||||
dateFormats.push_back("yy;M/yy;M/d/yy");
|
||||
dateFormats.push_back("yyyy;MM-yyyy;dd-MM-yyyy");
|
||||
dateFormats.push_back("yyyy;MM-yyyy;MM-dd-yyyy");
|
||||
dateFormats.push_back("yy;MM-yy;dd-MM-yy");
|
||||
dateFormats.push_back("yy;MM-yy;MM-dd-yy");
|
||||
|
||||
return dateFormats;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RiaQDateTimeTools::supportedTimeFormats()
|
||||
{
|
||||
std::vector<QString> timeFormats;
|
||||
|
||||
// See enum TimeFormatComponents in header
|
||||
// The semi-colon separated components are:
|
||||
// TIME_FORMAT_HOUR, ..HOUR_MINUTE, ..HOUR_MINUTE_SECOND and ..HOUR_MINUTE_MILLISECOND
|
||||
timeFormats.push_back("HH;HH:mm;HH:mm:ss;HH:mm:ss.zzz");
|
||||
timeFormats.push_back("H;H:mm;H:mm:ss;H:mm:ss.zzz");
|
||||
timeFormats.push_back("hh AP;hh:mm AP;hh:mm:ss AP;hh:mm:ss.zzz AP");
|
||||
timeFormats.push_back("h AP;h:mm AP;h:mm:ss AP;h:mm:ss.zzz AP");
|
||||
|
||||
return timeFormats;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaQDateTimeTools::dateFormatString(const QString& fullDateFormat, DateFormatComponents dateComponents)
|
||||
{
|
||||
if (dateComponents == DATE_FORMAT_NONE) return "";
|
||||
|
||||
QStringList allVariants = fullDateFormat.split(";");
|
||||
if (static_cast<int>(dateComponents) < allVariants.size())
|
||||
{
|
||||
return allVariants[dateComponents];
|
||||
}
|
||||
CVF_ASSERT(false && "Date format string is malformed");
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaQDateTimeTools::timeFormatString(const QString& fullTimeFormat, TimeFormatComponents timeComponents)
|
||||
{
|
||||
if (timeComponents == TIME_FORMAT_NONE) return "";
|
||||
|
||||
QStringList allVariants = fullTimeFormat.split(";");
|
||||
if (static_cast<int>(timeComponents) < allVariants.size())
|
||||
{
|
||||
return allVariants[timeComponents];
|
||||
}
|
||||
CVF_ASSERT(false && "Time format string is malformed");
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user