KShare/formatter.cpp
ArsenArsen 37ce6f1eda Add clang-format; Make text and blur less annoying
I didn't read the clang-format documentation properly
2017-05-09 17:26:00 +02:00

17 lines
522 B
C++

#include "formatter.hpp"
#include <QDateTime>
#include <QStringList>
QString formatter::format(QString toFormat) {
QRegExp dateRegex("%\\((.+)\\)date");
dateRegex.indexIn(toFormat);
QStringList capturedTexts(dateRegex.capturedTexts());
QString formatted(toFormat);
QDateTime date = QDateTime::currentDateTime();
for (int i = 0; i < capturedTexts.length(); i += 2) {
formatted = formatted.replace(capturedTexts.at(i), date.toString(capturedTexts.at(i + 1)));
}
return formatted;
}