Snippet: add ww as the week number with leading zero

This commit is contained in:
Le Tan 2021-08-12 21:24:42 +08:00
parent c03884c429
commit 0cf0da06f8

View File

@ -12,6 +12,7 @@
#include <core/configmgr.h> #include <core/configmgr.h>
#include <buffer/buffer.h> #include <buffer/buffer.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/utils.h>
#include <utils/pathutils.h> #include <utils/pathutils.h>
#include <vtextedit/vtextedit.h> #include <vtextedit/vtextedit.h>
#include <vtextedit/texteditutils.h> #include <vtextedit/texteditutils.h>
@ -349,6 +350,12 @@ QVector<QSharedPointer<Snippet>> SnippetMgr::loadBuiltInSnippets() const
[](const QString &) { [](const QString &) {
return QString::number(QDate::currentDate().weekNumber()); return QString::number(QDate::currentDate().weekNumber());
}); });
addDynamicSnippet(snippets,
"ww",
tr("the week number with a leading zero (`01` to `53`)"),
[](const QString &) {
return Utils::intToString(QDate::currentDate().weekNumber(), 2);
});
addDynamicSnippet(snippets, addDynamicSnippet(snippets,
"H", "H",
tr("the hour without a leading zero (`0` to `23` even with AM/PM display)"), tr("the hour without a leading zero (`0` to `23` even with AM/PM display)"),