mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-01 02:48:05 +01:00
added util function
This commit is contained in:
parent
0f737a1328
commit
ade6268eb1
@ -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('<h1>hello</h1>')` | 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.
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "core/filterutils.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QHostInfo>
|
||||
@ -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);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#ifndef FILTERUTILS_H
|
||||
#define FILTERUTILS_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDomElement>
|
||||
#include <QObject>
|
||||
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user