Fluid
Loading...
Searching...
No Matches
dateutils.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 * Copyright (C) 2018 Michael Spencer <sonrisesoftware@gmail.com>
6 *
7 * $BEGIN_LICENSE:MPL2$
8 *
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 *
13 * $END_LICENSE$
14 */
15
16#pragma once
17
18#include <QObject>
19#include <QDate>
20#include <QDateTime>
21#include <QQmlEngine>
22
23class DateUtils : public QObject
24{
25 Q_OBJECT
26 QML_ELEMENT
27 QML_SINGLETON
28public:
30 Q_ENUM(DurationFormat)
31
33 Q_ENUM(DurationType)
34
35 DateUtils(QObject *parent = nullptr);
36
37 Q_INVOKABLE QString formattedDate(const QDate &date) const;
38 Q_INVOKABLE QString formatDuration(qlonglong duration,
41 Q_INVOKABLE QString friendlyTime(const QDateTime &time, bool standalone) const;
42 Q_INVOKABLE QString dayOfWeek(const QDate &date) const;
43
44 static DateUtils *create(QQmlEngine *engine, QJSEngine *jsEngine);
45};
46
Definition dateutils.h:24
Q_INVOKABLE QString formatDuration(qlonglong duration, DateUtils::DurationFormat format=DateUtils::DurationFormat::Short, DateUtils::DurationType type=DateUtils::DurationType::Any) const
Definition dateutils.cpp:34
Q_INVOKABLE QString dayOfWeek(const QDate &date) const
Definition dateutils.cpp:99
Q_INVOKABLE QString friendlyTime(const QDateTime &time, bool standalone) const
Definition dateutils.cpp:75
Q_INVOKABLE QString formattedDate(const QDate &date) const
Definition dateutils.cpp:25
static DateUtils * create(QQmlEngine *engine, QJSEngine *jsEngine)
Definition dateutils.cpp:104
DurationType
Definition dateutils.h:32
@ Hours
Definition dateutils.h:32
@ Any
Definition dateutils.h:32
@ Minutes
Definition dateutils.h:32
@ Seconds
Definition dateutils.h:32
DurationFormat
Definition dateutils.h:29
@ Long
Definition dateutils.h:29
@ Short
Definition dateutils.h:29