Kgapi

utils.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "utils.h"
10
11#include <QDateTime>
12
13KGAPI2::ContentType Utils::stringToContentType(const QString &contentType)
14{
15 if (contentType.contains(QLatin1StringView("application/json")) || contentType.contains(QLatin1StringView("text/plain"))
16 || contentType.contains(QLatin1StringView("text/javascript"))) {
17 return KGAPI2::JSON;
18 } else if (contentType.contains(QLatin1StringView("application/atom+xml")) || contentType.contains(QLatin1StringView("text/xml"))) {
19 return KGAPI2::XML;
20 }
21
22 return KGAPI2::UnknownContentType;
23}
24
25QString Utils::bool2Str(bool val)
26{
27 return (val ? QStringLiteral("true") : QStringLiteral("false"));
28}
29
30QString Utils::ts2Str(quint64 ts)
31{
33}
34
35QDateTime Utils::rfc3339DateFromString(const QString &string)
36{
37 return QDateTime::fromString(string, Qt::ISODate);
38}
39
40QString Utils::rfc3339DateToString(const QDateTime &dt)
41{
42 return dt.toUTC().toString(Qt::ISODate);
43}
ContentType
Definition types.h:210
QDateTime fromSecsSinceEpoch(qint64 secs)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QString toString(QStringView format, QCalendar cal) const const
QDateTime toUTC() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.