MythTV  master
mythdate.h
Go to the documentation of this file.
1 #ifndef MYTH_DATE_H
2 #define MYTH_DATE_H
3 
4 #include <chrono>
5 using namespace std::chrono_literals;
6 
7 #include <QDateTime>
8 #include <QString>
9 
10 #include "mythbaseexp.h"
11 
12 namespace MythDate
13 {
14 
15 enum Format
16 {
18  kFilename = 0x000100,
19  kDateFull = 0x000200,
20  kDateShort = 0x000400,
22  kTime = 0x000800,
25  kAddYear = 0x001000,
26  kSimplify = 0x002000,
27  kDatabase = 0x004000,
28  kAutoYear = 0x008000,
29  kScreenShotFilename = 0x010000,
30  kRFC822 = 0x020000,
31  kOverrideUTC = 0x100000,
32  kOverrideLocal = 0x200000,
33 };
34 
37 MBASE_PUBLIC QDateTime current(bool stripped = false);
40 MBASE_PUBLIC QString current_iso_string(bool stripped = false);
42 MBASE_PUBLIC QDateTime as_utc(const QDateTime &dt);
43 
45 MBASE_PUBLIC QDateTime fromString(const QString &dtstr);
47 MBASE_PUBLIC QDateTime fromString(const QString &dt, const QString &format);
48 MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds);
50 MBASE_PUBLIC QString toString(
51  const QDateTime &datetime, uint format = MythDate::kDateTimeFull);
53 MBASE_PUBLIC QString toString(
54  QDate date, uint format = MythDate::kDateFull);
55 
56 // Returns the total number of seconds since midnight
57 MBASE_PUBLIC std::chrono::seconds toSeconds( QTime time );
58 
59 MBASE_PUBLIC std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void);
60 MBASE_PUBLIC std::chrono::seconds secsInPast (const QDateTime& past);
61 MBASE_PUBLIC std::chrono::seconds secsInFuture (const QDateTime& future);
62 
63 };
64 
65 #endif // MYTH_DATE_H
MythDate::as_utc
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:23
mythbaseexp.h
MythDate::kScreenShotFilename
@ kScreenShotFilename
"yyyy-MM-ddThh-mm-ss.zzz"
Definition: mythdate.h:29
MythDate::kOverrideUTC
@ kOverrideUTC
Present date/time in UTC.
Definition: mythdate.h:31
MythDate::Format
Format
Definition: mythdate.h:15
MythDate::kDateTimeShort
@ kDateTimeShort
Default local time.
Definition: mythdate.h:24
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
MythDate::secsInFuture
std::chrono::seconds secsInFuture(const QDateTime &future)
Definition: mythdate.cpp:204
MythDate::fromSecsSinceEpoch
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
Definition: mythdate.cpp:68
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythDate::kFilename
@ kFilename
Default UTC, "yyyyMMddhhmmss".
Definition: mythdate.h:18
MythDate::kDateEither
@ kDateEither
Default local time.
Definition: mythdate.h:21
MythDate::kOverrideLocal
@ kOverrideLocal
Present date/time in localtime.
Definition: mythdate.h:32
MythDate::kAutoYear
@ kAutoYear
Add year only if different from current year.
Definition: mythdate.h:28
MythDate::kDateShort
@ kDateShort
Default local time.
Definition: mythdate.h:20
uint
unsigned int uint
Definition: compat.h:144
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
MythDate::kSimplify
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:26
MythDate::currentMSecsSinceEpochAsDuration
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
Definition: mythdate.cpp:194
MythDate::secsInPast
std::chrono::seconds secsInPast(const QDateTime &past)
Definition: mythdate.cpp:199
MythDate::kAddYear
@ kAddYear
Add year to string if not included.
Definition: mythdate.h:25
MythDate::kRFC822
@ kRFC822
HTTP Date format.
Definition: mythdate.h:30
MythDate
Definition: mythdate.cpp:7
MythDate::ISODate
@ ISODate
Default UTC.
Definition: mythdate.h:17
MythDate::current_iso_string
QString current_iso_string(bool stripped)
Returns current Date and Time in UTC as a string.
Definition: mythdate.cpp:18
MythDate::kDatabase
@ kDatabase
Default UTC, database format.
Definition: mythdate.h:27
MythDate::kDateFull
@ kDateFull
Default local time.
Definition: mythdate.h:19
MythDate::toSeconds
std::chrono::seconds toSeconds(QTime time)
Returns the total number of seconds since midnight of the supplied QTime.
Definition: mythdate.cpp:182
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:23
MythDate::kTime
@ kTime
Default local time.
Definition: mythdate.h:22