diff --git a/doc/src/projects/creator-projects-custom-wizards.qdoc b/doc/src/projects/creator-projects-custom-wizards.qdoc index 943d5572068..d4fc42504cb 100644 --- a/doc/src/projects/creator-projects-custom-wizards.qdoc +++ b/doc/src/projects/creator-projects-custom-wizards.qdoc @@ -585,10 +585,28 @@ which is also defined in \gui {File Naming}. \li \c {%CurrentDate%} is replaced by the current date in the format - \c {yyyy-MM-dd}. + \c {YYYY-MM-DD} as specified by ISO 8601. - \li \c {%CurrentTime%} is replaced by the current time in the short - format of the locale. + \li \c {%CurrentTime%} is replaced by the current time in the format + \c {HH:MM:SS} as specified by ISO 8601. + + \li \c {%CurrentDate:Locale%} is replaced by the current date in the short format + specified by the application's locale. + + \li \c {%CurrentTime:Locale%} is replaced by the current time in the short format + specified by the application's locale. + + \li \c {%CurrentDate:ISO%} is replaced by the current date in the format + \c {YYYY-MM-DD} as specified by ISO 8601. + + \li \c {%CurrentTime:ISO%} is replaced by the current time in the format + \c {HH:MM:SS} as specified by ISO 8601. + + \li \c {%CurrentDate:RFC%} is replaced by the current date in the format + \c {DD Mon YYYY}, where \c {Mon} is the three letter month name, as specified by RFC 2822. + + \li \c {%CurrentTime:RFC%} is replaced by the current time in the format + \c {HH:MM:SS} as specified by RFC 2822. \endlist diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 379819824ff..18819336233 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -498,12 +498,6 @@ QMap CustomWizardFieldPage::replacementMap(const QWizard *w, fieldReplacementMap.insert(QLatin1String("Path"), QDir::toNativeSeparators(ctx->path)); fieldReplacementMap.insert(QLatin1String("TargetPath"), QDir::toNativeSeparators(ctx->targetPath)); - // Insert additional pre-defined variables - fieldReplacementMap.insert(QLatin1String("CurrentDate"), - QDate::currentDate().toString(QLatin1String("yyyy-MM-dd"))); - fieldReplacementMap.insert(QLatin1String("CurrentTime"), - QTime::currentTime().toString(QLocale::system(). - timeFormat(QLocale::ShortFormat))); return fieldReplacementMap; } diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index ff45d9b0466..46ae852e3cb 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -37,17 +37,18 @@ #include -#include #include -#include +#include +#include #include +#include #include -#include -#include -#include -#include - #include +#include +#include +#include +#include +#include enum { debug = 0 }; @@ -969,12 +970,30 @@ bool CustomWizardContext::replaceFields(const FieldReplacementMap &fm, QString * void CustomWizardContext::reset() { - // Basic replacement fields: Suffixes. + // Basic replacement fields: Suffixes and date/time. + const QDate currentDate = QDate::currentDate(); + const QTime currentTime = QTime::currentTime(); baseReplacements.clear(); baseReplacements.insert(QLatin1String("CppSourceSuffix"), MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))); baseReplacements.insert(QLatin1String("CppHeaderSuffix"), MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))); + baseReplacements.insert(QLatin1String("CurrentDate"), + currentDate.toString(Qt::ISODate)); + baseReplacements.insert(QLatin1String("CurrentTime"), + currentTime.toString(Qt::ISODate)); + baseReplacements.insert(QLatin1String("CurrentDate:ISO"), + currentDate.toString(Qt::ISODate)); + baseReplacements.insert(QLatin1String("CurrentTime:ISO"), + currentTime.toString(Qt::ISODate)); + baseReplacements.insert(QLatin1String("CurrentDate:RFC"), + currentDate.toString(Qt::RFC2822Date)); + baseReplacements.insert(QLatin1String("CurrentTime:RFC"), + currentTime.toString(Qt::RFC2822Date)); + baseReplacements.insert(QLatin1String("CurrentDate:Locale"), + currentDate.toString(Qt::DefaultLocaleShortDate)); + baseReplacements.insert(QLatin1String("CurrentTime:Locale"), + currentTime.toString(Qt::DefaultLocaleShortDate)); replacements.clear(); path.clear(); targetPath.clear();