blob: bb083497e89b85c46d28d72dfa4246107095d20f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#ifndef OPIE_TIME_ZONE_H
#define OPIE_TIME_ZONE_H
#include <time.h>
#include <qdatetime.h>
/**
* A very primitive class to convert time
* from one timezone to another
* and to localtime
* and time_t
*/
class OTimeZone {
public:
typedef QString ZoneName;
OTimeZone( const ZoneName& = ZoneName::null );
virtual ~OTimeZone(); // just in case.
bool isValid()const;
/**
* converts the QDateTime to a DateTime
* in the local timezone
* if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h
* and the current timezone is Europe/London the returned
* time will be 11h.
*/
QDateTime toLocalDateTime( const QDateTime& dt );
/**
* converts the QDateTime to UTC time
*/
QDateTime toUTCDateTime( const QDateTime& dt );
/**
* reads the time_t into a QDateTime using UTC as timezone!
*/
QDateTime fromUTCDateTime( time_t );
/**
* converts the time_t to the time in the timezone
*/
QDateTime toDateTime( time_t );
/**
* converts the QDateTime from one timezone to this timeZone
*/
QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone );
/**
* converts the date time into a time_t. It takes the timezone into account
*/
time_t fromDateTime( const QDateTime& );
/**
* converts the datetime with timezone UTC
*/
time_t fromUTCDateTime( const QDateTime& );
static OTimeZone current();
static OTimeZone utc();
QString timeZone()const;
private:
ZoneName m_name;
class Private;
Private* d;
};
#endif
|