Commit f13c822a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add support for "Last Month Name Long"

Requested by David
parent bb626a06
Pipeline #26456 failed with stage
in 66 minutes and 44 seconds
......@@ -52,4 +52,5 @@ void ConvertSnippetVariablesUtilTest::shouldTranslateVariables()
QCOMPARE(MessageComposer::ConvertSnippetVariablesUtil::snippetVariableFromEnum(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeekNameShort), QStringLiteral("%DAYOFWEEKNAMESHORT"));
QCOMPARE(MessageComposer::ConvertSnippetVariablesUtil::snippetVariableFromEnum(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeekNameLong), QStringLiteral("%DAYOFWEEKNAMELONG"));
QCOMPARE(MessageComposer::ConvertSnippetVariablesUtil::snippetVariableFromEnum(MessageComposer::ConvertSnippetVariablesUtil::YearLastMonth), QStringLiteral("%YEARLASTMONTH"));
QCOMPARE(MessageComposer::ConvertSnippetVariablesUtil::snippetVariableFromEnum(MessageComposer::ConvertSnippetVariablesUtil::LastMonthNameLong), QStringLiteral("%LASTMONTHNAMELONG"));
}
......@@ -134,6 +134,9 @@ void ConvertSnippetVariableMenu::initializeMenu(bool onlyMenuForCustomizeAttachm
dateTimeMenuVariable->addAction(i18n("Month Name Long (%1)", MessageComposer::ConvertSnippetVariablesUtil::monthNameLong()), this, [this]() {
Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::MonthNameLong);
});
dateTimeMenuVariable->addAction(i18n("Last Month Name Long (%1)", MessageComposer::ConvertSnippetVariablesUtil::lastMonthNameLong()), this, [this]() {
Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::LastMonthNameLong);
});
dateTimeMenuVariable->addAction(i18n("Day Of Week (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfWeek()), this, [this]() {
Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeek);
});
......
......@@ -101,6 +101,9 @@ QString ConvertSnippetVariablesJob::convertVariables(const QString &cmd, int &i,
} else if (cmd.startsWith(QLatin1String("DAYOFWEEK"))) {
i += strlen("DAYOFWEEK");
result.append(MessageComposer::ConvertSnippetVariablesUtil::dayOfWeek());
} else if (cmd.startsWith(QLatin1String("LASTMONTHNAMELONG"))) {
i += strlen("LASTMONTHNAMELONG");
result.append(MessageComposer::ConvertSnippetVariablesUtil::lastMonthNameLong());
} else {
result.append(c);
}
......
......@@ -80,6 +80,8 @@ QString MessageComposer::ConvertSnippetVariablesUtil::snippetVariableFromEnum(Me
return QStringLiteral("%DAYOFWEEKNAMELONG"); //(Monday-Sunday)
case YearLastMonth:
return QStringLiteral("%YEARLASTMONTH"); //january 2020 will how 2019-12
case LastMonthNameLong:
return QStringLiteral("%LASTMONTHNAMELONG");
}
return {};
}
......@@ -157,6 +159,12 @@ QString MessageComposer::ConvertSnippetVariablesUtil::monthNameLong()
return date.toString(QStringLiteral("MMMM"));
}
QString MessageComposer::ConvertSnippetVariablesUtil::lastMonthNameLong()
{
const QDate date = QDate::currentDate().addMonths(-1);
return date.toString(QStringLiteral("MMMM"));
}
QString MessageComposer::ConvertSnippetVariablesUtil::dayOfWeekNameShort()
{
const QDate date = QDate::currentDate();
......
......@@ -45,7 +45,8 @@ enum VariableType {
DayOfWeek,
DayOfWeekNameShort,
DayOfWeekNameLong,
YearLastMonth
YearLastMonth,
LastMonthNameLong
};
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString snippetVariableFromEnum(MessageComposer::ConvertSnippetVariablesUtil::VariableType type);
......@@ -68,6 +69,7 @@ Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString dayOfWeekNameLong();
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString yearLastMonth();
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString year();
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString dayOfWeek();
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString lastMonthNameLong();
}
}
#endif // CONVERTSNIPPETVARIABLESUTIL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment