|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CALENDATEUTILS_H__ |
|
19 #define __CALENDATEUTILS_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <qglobal.h> // Q_DECL_EXPORT macro |
|
23 |
|
24 #ifdef CALENDATEUTILS_DLL |
|
25 #define CALENDATEUTIL_EXPORT Q_DECL_EXPORT |
|
26 #else |
|
27 #define CALENDATEUTIL_EXPORT Q_DECL_IMPORT |
|
28 #endif |
|
29 |
|
30 // forward declarations |
|
31 class QDateTime; |
|
32 |
|
33 /** |
|
34 * CalenDateUtils contains static utility functions useful |
|
35 * when comparing and calculating with dates and times. |
|
36 * |
|
37 * @lib Calendar.app |
|
38 * @since 2.1 |
|
39 */ |
|
40 |
|
41 class CALENDATEUTIL_EXPORT CalenDateUtils |
|
42 { |
|
43 public: |
|
44 static bool onSameDay( const QDateTime& x, const QDateTime& y ); |
|
45 static bool onSameMonth( const QDateTime& x, const QDateTime& y ); |
|
46 static QDateTime beginningOfDay( const QDateTime& startTime ); |
|
47 static QDateTime displayTimeOnDay( const QDateTime& startTime, |
|
48 const QDateTime& day ); |
|
49 |
|
50 static bool timeRangesIntersect( const QDateTime& xStart, |
|
51 const QDateTime& xEnd, |
|
52 const QDateTime& yStart, |
|
53 const QDateTime& yEnd ); |
|
54 |
|
55 /** |
|
56 * Is aTime between KCalenMaxYear/KCalenMaxMonth/KCalenMaxDay |
|
57 * and KCalenMinYear/KCalenMinMonth/KCalenMinDay. |
|
58 * Min/Max day is defined agenda server. |
|
59 * @param aTime aTime to be checked |
|
60 * @return EFalse : Out of range |
|
61 */ |
|
62 static bool isValidDay( const QDateTime& time ); |
|
63 |
|
64 /** |
|
65 * Return ETrue if aTime is NULL |
|
66 * @param aTime time to be compared against NULL time |
|
67 */ |
|
68 static bool isNullTime( QDateTime& time ); |
|
69 |
|
70 /** |
|
71 * Return Min or Max time if aTime goes out of bounds. |
|
72 * Valid range is [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime] |
|
73 * @param aTime time to be checked |
|
74 * @return aTime, if aTime in [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime] |
|
75 * CalenDateUtils::MinTime(), if aTime < CalenDateUtils::MinTime() |
|
76 * CalenDateUtils::MaxTime(), if aTime > CalenDateUtils::MaxTime() |
|
77 */ |
|
78 static QDateTime limitToValidTime( const QDateTime& time ); |
|
79 |
|
80 /** |
|
81 * Return maximum allowed time. (31. |
|
82 */ |
|
83 static QDateTime maxTime(); |
|
84 |
|
85 /** |
|
86 * Return minimum allowed time. |
|
87 */ |
|
88 static QDateTime minTime(); |
|
89 |
|
90 /** |
|
91 * Return time of day as a minutes from midnight. Useful to get hours::minutes component of datetime, |
|
92 * regardless of date |
|
93 */ |
|
94 static int timeOfDay( const QDateTime& dateTime ); |
|
95 |
|
96 /** |
|
97 * Round QDateTime to previous full hour, e.g. RoundToPreviousHour( 23.11.2006 9:31 ) = 23.11.2006 9:00 |
|
98 */ |
|
99 static QDateTime roundToPreviousHour( const QDateTime& dateTime ); |
|
100 |
|
101 /** |
|
102 * Round QDateTimeIntervalMinutes to previous full hour, e.g. RoundToPreviousHour( 130 min ) = 120 min |
|
103 */ |
|
104 static int roundToPreviousHour( const int& minutes ); |
|
105 |
|
106 |
|
107 /** |
|
108 * @return current time. |
|
109 */ |
|
110 static QDateTime now(); |
|
111 |
|
112 /** |
|
113 * @return today with time component set to 00:00. |
|
114 */ |
|
115 static QDateTime today(); |
|
116 |
|
117 /** |
|
118 * @return ETrue if given aTime is on today, EFalse otherwise |
|
119 */ |
|
120 static bool isOnToday( const QDateTime& time ); |
|
121 |
|
122 /* |
|
123 * Given aDate = DD::MM::YY @ hh:mm:ss, it returns a QDateTime obj DD::MM::YY @ 08:00 am |
|
124 * @param: aDate, which has the DD::MM::YY |
|
125 */ |
|
126 static QDateTime defaultTime( const QDateTime& date ); |
|
127 |
|
128 static QDateTime pastOf(const QDateTime& dateTime, int numOfDays); |
|
129 |
|
130 static QDateTime futureOf(const QDateTime& dateTime, int numOfDays); |
|
131 |
|
132 |
|
133 private: |
|
134 // Hiding constructor, because this is static utility class. |
|
135 //lint -e{1526} |
|
136 CalenDateUtils(); |
|
137 |
|
138 // Hiding assignment, because this is static utility class. |
|
139 //lint -e{1526} |
|
140 CalenDateUtils& operator=( const CalenDateUtils& ); |
|
141 |
|
142 }; |
|
143 |
|
144 #endif // __CALENDATEUTILS_H__ |
|
145 |
|
146 |
|
147 // End of File |