MythTV  master
mythdate.h
Go to the documentation of this file.
1 #ifndef MYTH_DATE_H
2 #define MYTH_DATE_H
3 
4 #include <QDateTime>
5 #include <QString>
6 
7 #include "mythbaseexp.h"
8 
9 namespace MythDate
10 {
11 
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 };
31 
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);
40 
42 MBASE_PUBLIC QDateTime fromString(const QString &dtstr);
44 MBASE_PUBLIC QDateTime fromString(const QString &dt, const QString &format);
45 MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds);
47 MBASE_PUBLIC QString toString(
48  const QDateTime &datetime, uint format = MythDate::kDateTimeFull);
50 MBASE_PUBLIC QString toString(
51  const QDate &date, uint format = MythDate::kDateFull);
52 
53 // Returns the total number of seconds since midnight
54 MBASE_PUBLIC int toSeconds( const QTime &time );
55 
56 };
57 
58 #endif // MYTH_DATE_H
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:80
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::toSeconds
int toSeconds(const QTime &time)
Returns the total number of seconds since midnight of the supplied QTime.
Definition: mythdate.cpp:182
MythDate::kScreenShotFilename
@ kScreenShotFilename
"yyyy-MM-ddThh-mm-ss.zzz"
Definition: mythdate.h:26
MythDate::kOverrideUTC
@ kOverrideUTC
Present date/time in UTC.
Definition: mythdate.h:28
MythDate::Format
Format
Definition: mythdate.h:13
MythDate::kDateTimeShort
@ kDateTimeShort
Default local time.
Definition: mythdate.h:21
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
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
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythDate::kFilename
@ kFilename
Default UTC, "yyyyMMddhhmmss".
Definition: mythdate.h:15
MythDate::kDateEither
@ kDateEither
Default local time.
Definition: mythdate.h:18
MythDate::kOverrideLocal
@ kOverrideLocal
Present date/time in localtime.
Definition: mythdate.h:29
MythDate::kAutoYear
@ kAutoYear
Add year only if different from current year.
Definition: mythdate.h:25
MythDate::kDateShort
@ kDateShort
Default local time.
Definition: mythdate.h:17
uint
unsigned int uint
Definition: compat.h:140
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:23
MythDate::kAddYear
@ kAddYear
Add year to string if not included.
Definition: mythdate.h:22
MythDate::kRFC822
@ kRFC822
HTTP Date format.
Definition: mythdate.h:27
MythDate
Definition: mythdate.cpp:8
MythDate::ISODate
@ ISODate
Default UTC.
Definition: mythdate.h:14
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:24
MythDate::kDateFull
@ kDateFull
Default local time.
Definition: mythdate.h:16
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:20
MythDate::kTime
@ kTime
Default local time.
Definition: mythdate.h:19