libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
DateTime.h
1/*
2 * Copyright 2020-2024 Dmitry Ivanov
3 *
4 * This file is part of libquentier
5 *
6 * libquentier is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, version 3 of the License.
9 *
10 * libquentier is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include <quentier/utility/Linkage.h>
22
23#include <QFlags>
24
25namespace quentier {
26
27[[nodiscard]] constexpr int secondsToMilliseconds(int seconds) noexcept
28{
29 return seconds * 1000;
30}
31
35enum class DateTimePrintOption
36{
41 IncludeNumericTimestamp = 1 << 1,
45 IncludeMilliseconds = 1 << 2,
51 IncludeTimezone = 1 << 3
52};
53
54Q_DECLARE_FLAGS(DateTimePrintOptions, DateTimePrintOption)
55Q_DECLARE_OPERATORS_FOR_FLAGS(DateTimePrintOptions)
56
57
74[[nodiscard]] QString QUENTIER_EXPORT printableDateTimeFromTimestamp(
75 qint64 timestamp,
76 DateTimePrintOptions options = DateTimePrintOptions(
77 DateTimePrintOption::IncludeNumericTimestamp |
78 DateTimePrintOption::IncludeMilliseconds |
79 DateTimePrintOption::IncludeTimezone),
80 const char * customFormat = nullptr);
81
82} // namespace quentier