From ade6268eb102ed7a3b9797f06ce810f60d02ad10 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 27 May 2021 08:25:31 +0200 Subject: [PATCH] added util function --- resources/docs/Message-filters.md | 1 + src/librssguard/core/filterutils.cpp | 5 +++++ src/librssguard/core/filterutils.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/resources/docs/Message-filters.md b/resources/docs/Message-filters.md index d07d9c760..030bd13ab 100755 --- a/resources/docs/Message-filters.md +++ b/resources/docs/Message-filters.md @@ -91,6 +91,7 @@ Note that `MessageObject` attributes which can be synchronized back to service a |---|---|---| | `String hostname()` | `utils.hostname()` | Returns name of your PC. | | `String fromXmlToJson(String)` | `utils.fromXmlToJson('

hello

')` | Converts `XML` string into `JSON`. | +| `Date parseDateTime(String)` | `utils.parseDateTime('2020-02-24T08:00:00')` | Converts textual date/time representation into proper `Date` object. | ## Examples Accept only messages from "Bob" while also marking them important. diff --git a/src/librssguard/core/filterutils.cpp b/src/librssguard/core/filterutils.cpp index 759c60154..1c9cc38e2 100755 --- a/src/librssguard/core/filterutils.cpp +++ b/src/librssguard/core/filterutils.cpp @@ -3,6 +3,7 @@ #include "core/filterutils.h" #include "definitions/definitions.h" +#include "miscellaneous/textfactory.h" #include #include @@ -70,3 +71,7 @@ QString FilterUtils::fromXmlToJson(const QString& xml) const { return QSL("{\"%1\": %2}").arg(xml_doc.documentElement().tagName(), json); } + +QDateTime FilterUtils::parseDateTime(const QString& dat) const { + return TextFactory::parseDateTime(dat); +} diff --git a/src/librssguard/core/filterutils.h b/src/librssguard/core/filterutils.h index 1baf99a2f..565836254 100755 --- a/src/librssguard/core/filterutils.h +++ b/src/librssguard/core/filterutils.h @@ -3,6 +3,7 @@ #ifndef FILTERUTILS_H #define FILTERUTILS_H +#include #include #include @@ -18,6 +19,9 @@ class FilterUtils : public QObject { // Converts XML -> JSON or returns empty string if failed. Q_INVOKABLE QString fromXmlToJson(const QString& xml) const; + + // Parses string into date/time object. + Q_INVOKABLE QDateTime parseDateTime(const QString& dat) const; }; #endif // FILTERUTILS_H