calendarui/inc/calendateutils.h
changeset 75 7ac58b2aae6f
parent 72 27feeedec790
child 79 6ff09f16627b
child 81 ce92091cbd61
equal deleted inserted replaced
72:27feeedec790 75:7ac58b2aae6f
     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 Min or Max time if aTime goes out of bounds. 
       
    66      * Valid range is [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime]
       
    67      * @param aTime time to be checked
       
    68      * @return aTime, if aTime in [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime]
       
    69      *         CalenDateUtils::MinTime(), if aTime < CalenDateUtils::MinTime()
       
    70      *         CalenDateUtils::MaxTime(), if aTime > CalenDateUtils::MaxTime()
       
    71      */
       
    72     static QDateTime limitToValidTime( const QDateTime& time );
       
    73 
       
    74     /**
       
    75      * Return maximum allowed time. (31.
       
    76      */
       
    77     static QDateTime maxTime();
       
    78 
       
    79     /**
       
    80      * Return minimum allowed time.
       
    81      */
       
    82     static QDateTime minTime();
       
    83 
       
    84     /**
       
    85      * Return time of day as a minutes from midnight. Useful to get hours::minutes component of datetime, 
       
    86      * regardless of date
       
    87      */
       
    88     static int timeOfDay( const QDateTime& dateTime );
       
    89 
       
    90     /**
       
    91      * Round QDateTime to previous full hour, e.g. RoundToPreviousHour( 23.11.2006 9:31 ) = 23.11.2006 9:00
       
    92      */
       
    93     static QDateTime roundToPreviousHour( const QDateTime& dateTime );
       
    94 
       
    95     /**
       
    96      * Round QDateTimeIntervalMinutes to previous full hour, e.g. RoundToPreviousHour( 130 min ) = 120 min
       
    97      */
       
    98     static int roundToPreviousHour( const int& minutes );
       
    99     
       
   100 
       
   101     /**
       
   102      * @return current time. 
       
   103      */ 
       
   104     static QDateTime now();
       
   105     
       
   106     /**
       
   107      * @return today with time component set to 00:00. 
       
   108      */ 
       
   109     static QDateTime today();
       
   110 
       
   111     /**
       
   112      * @return ETrue if given aTime is on today, EFalse otherwise
       
   113      */     
       
   114     static bool isOnToday( const QDateTime& time );
       
   115 
       
   116     /* 
       
   117      * Given aDate = DD::MM::YY @ hh:mm:ss, it returns a QDateTime obj DD::MM::YY @ 08:00 am
       
   118      * @param: aDate, which has the DD::MM::YY
       
   119      */
       
   120     static QDateTime defaultTime( const QDateTime& date );
       
   121     
       
   122     static QDateTime futureOf(const QDateTime& dateTime, int numOfDays);
       
   123     
       
   124    
       
   125 private:
       
   126     // Hiding constructor, because this is static utility class.
       
   127     //lint -e{1526} 
       
   128     CalenDateUtils();
       
   129 
       
   130     // Hiding assignment, because this is static utility class.
       
   131     //lint -e{1526} 
       
   132     CalenDateUtils& operator=( const CalenDateUtils& );
       
   133 
       
   134     };
       
   135 
       
   136 #endif // __CALENDATEUTILS_H__
       
   137 
       
   138 
       
   139 // End of File