Diffstat (limited to 'libopie2/opiepim/core/otimezone.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/otimezone.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libopie2/opiepim/core/otimezone.h b/libopie2/opiepim/core/otimezone.h index 28ae6cb..f0b4022 100644 --- a/libopie2/opiepim/core/otimezone.h +++ b/libopie2/opiepim/core/otimezone.h | |||
@@ -6,63 +6,67 @@ | |||
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIE_TIME_ZONE_H | 30 | #ifndef OTIMEZONE_H |
31 | #define OPIE_TIME_ZONE_H | 31 | #define OTIMEZONE_H |
32 | 32 | ||
33 | #include <time.h> | 33 | /* QT */ |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | 35 | ||
36 | /* STD */ | ||
37 | #include <time.h> | ||
38 | |||
36 | namespace Opie | 39 | namespace Opie |
37 | { | 40 | { |
38 | /** | 41 | /** |
39 | * A very primitive class to convert time | 42 | * A very primitive class to convert time |
40 | * from one timezone to another | 43 | * from one timezone to another |
41 | * and to localtime | 44 | * and to localtime |
42 | * and time_t | 45 | * and time_t |
43 | */ | 46 | */ |
44 | class OTimeZone { | 47 | class OTimeZone { |
48 | |||
45 | public: | 49 | public: |
46 | typedef QString ZoneName; | 50 | typedef QString ZoneName; |
47 | OTimeZone( const ZoneName& = ZoneName::null ); | 51 | OTimeZone( const ZoneName& = ZoneName::null ); |
48 | virtual ~OTimeZone(); // just in case. | 52 | virtual ~OTimeZone(); // just in case. |
49 | 53 | ||
50 | bool isValid()const; | 54 | bool isValid()const; |
51 | 55 | ||
52 | /** | 56 | /** |
53 | * converts the QDateTime to a DateTime | 57 | * converts the QDateTime to a DateTime |
54 | * in the local timezone | 58 | * in the local timezone |
55 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h | 59 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h |
56 | * and the current timezone is Europe/London the returned | 60 | * and the current timezone is Europe/London the returned |
57 | * time will be 11h. | 61 | * time will be 11h. |
58 | */ | 62 | */ |
59 | QDateTime toLocalDateTime( const QDateTime& dt ); | 63 | QDateTime toLocalDateTime( const QDateTime& dt ); |
60 | 64 | ||
61 | /** | 65 | /** |
62 | * converts the QDateTime to UTC time | 66 | * converts the QDateTime to UTC time |
63 | */ | 67 | */ |
64 | QDateTime toUTCDateTime( const QDateTime& dt ); | 68 | QDateTime toUTCDateTime( const QDateTime& dt ); |
65 | 69 | ||
66 | /** | 70 | /** |
67 | * reads the time_t into a QDateTime using UTC as timezone! | 71 | * reads the time_t into a QDateTime using UTC as timezone! |
68 | */ | 72 | */ |
@@ -70,33 +74,34 @@ class OTimeZone { | |||
70 | 74 | ||
71 | /** | 75 | /** |
72 | * converts the time_t to the time in the timezone | 76 | * converts the time_t to the time in the timezone |
73 | */ | 77 | */ |
74 | QDateTime toDateTime( time_t ); | 78 | QDateTime toDateTime( time_t ); |
75 | 79 | ||
76 | /** | 80 | /** |
77 | * converts the QDateTime from one timezone to this timeZone | 81 | * converts the QDateTime from one timezone to this timeZone |
78 | */ | 82 | */ |
79 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); | 83 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); |
80 | 84 | ||
81 | /** | 85 | /** |
82 | * converts the date time into a time_t. It takes the timezone into account | 86 | * converts the date time into a time_t. It takes the timezone into account |
83 | */ | 87 | */ |
84 | time_t fromDateTime( const QDateTime& ); | 88 | time_t fromDateTime( const QDateTime& ); |
85 | 89 | ||
86 | /** | 90 | /** |
87 | * converts the datetime with timezone UTC | 91 | * converts the datetime with timezone UTC |
88 | */ | 92 | */ |
89 | time_t fromUTCDateTime( const QDateTime& ); | 93 | time_t fromUTCDateTime( const QDateTime& ); |
90 | 94 | ||
91 | static OTimeZone current(); | 95 | static OTimeZone current(); |
92 | static OTimeZone utc(); | 96 | static OTimeZone utc(); |
93 | 97 | ||
94 | QString timeZone()const; | 98 | QString timeZone() const; |
99 | |||
95 | private: | 100 | private: |
96 | ZoneName m_name; | 101 | ZoneName m_name; |
97 | class Private; | 102 | class Private; |
98 | Private* d; | 103 | Private* d; |
99 | }; | 104 | }; |
100 | }; | 105 | }; |
101 | 106 | ||
102 | #endif | 107 | #endif |