MythTV  master
Go to the documentation of this file.
1 #ifndef MYTH_DATE_H
2 #define MYTH_DATE_H
4 #include <QDateTime>
5 #include <QString>
7 #include "mythbaseexp.h"
9 namespace MythDate
10 {
12 enum Format
13 {
15  kFilename = 0x000100,
16  kDateFull = 0x000200,
17  kDateShort = 0x000400,
19  kTime = 0x000800,
22  kAddYear = 0x001000,
23  kSimplify = 0x002000,
24  kDatabase = 0x004000,
25  kAutoYear = 0x008000,
26  kScreenShotFilename = 0x010000,
27  kRFC822 = 0x020000,
28  kOverrideUTC = 0x100000,
29  kOverrideLocal = 0x200000,
30 };
34 MBASE_PUBLIC QDateTime current(bool stripped = false);
37 MBASE_PUBLIC QString current_iso_string(bool stripped = false);
39 MBASE_PUBLIC QDateTime as_utc(const QDateTime &dt);
42 MBASE_PUBLIC QDateTime fromString(const QString &dtstr);
44 MBASE_PUBLIC QDateTime fromString(const QString &dt, const QString &format);
46 MBASE_PUBLIC QDateTime fromTime_t(uint seconds);
47 #else
48 MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds);
49 #endif
50 MBASE_PUBLIC QString toString(
52  const QDateTime &datetime, uint format = MythDate::kDateTimeFull);
54 MBASE_PUBLIC QString toString(
55  const QDate &date, uint format = MythDate::kDateFull);
57 // Returns the total number of seconds since midnight
58 MBASE_PUBLIC int toSeconds( const QTime &time );
60 };
62 #endif // MYTH_DATE_H
Add year only if different from current year.
Definition: mythdate.h:25
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
QString current_iso_string(bool stripped)
Returns current Date and Time in UTC as a string.
Definition: mythdate.cpp:18
int toSeconds(const QTime &time)
Returns the total number of seconds since midnight of the supplied QTime.
Definition: mythdate.cpp:203
Present date/time in UTC.
Definition: mythdate.h:28
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:23
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:23
Definition: mythbaseexp.h:15
Default local time.
Definition: mythdate.h:20
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:88
Default UTC, database format.
Definition: mythdate.h:24
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
Default local time.
Definition: mythdate.h:16
Add year to string if not included.
Definition: mythdate.h:22
Default local time.
Definition: mythdate.h:18
unsigned int uint
Definition: compat.h:140
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
Default local time.
Definition: mythdate.h:17
Present date/time in localtime.
Definition: mythdate.h:29
Definition: mythdate.h:26
Default UTC.
Definition: mythdate.h:14
HTTP Date format.
Definition: mythdate.h:27
Default UTC, "yyyyMMddhhmmss".
Definition: mythdate.h:15
Default local time.
Definition: mythdate.h:21
Default local time.
Definition: mythdate.h:19