calendarui/organizerplugin/aiagendapluginengine/inc/calendateutils.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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 <calcommon.h>
       
    23 
       
    24 
       
    25 /**
       
    26  *  CalenDateUtils contains static utility functions useful
       
    27  *  when comparing and calculating with dates and times.
       
    28  *
       
    29  *  @lib Calendar.app
       
    30  *  @since 2.1
       
    31  */
       
    32 NONSHARABLE_CLASS( CalenDateUtils )
       
    33     {
       
    34 public:
       
    35     IMPORT_C static TBool OnSameDay( const TTime& aX, const TTime& aY );
       
    36     IMPORT_C static TBool OnSameMonth( const TTime& aX, const TTime& aY );
       
    37     IMPORT_C static TTime BeginningOfDay( const TTime& aStartTime );
       
    38     IMPORT_C static TTime DisplayTimeOnDay( const TTime& aStartTime, 
       
    39                                             const TTime& aDay );
       
    40 
       
    41     IMPORT_C static TBool TimeRangesIntersect( const TTime& aXStart,
       
    42                                                const TTime& aXEnd,
       
    43                                                const TTime& aYStart, 
       
    44                                                const TTime& aYEnd );
       
    45 
       
    46     /**
       
    47      * Is aTime between KCalenMaxYear/KCalenMaxMonth/KCalenMaxDay
       
    48      * and KCalenMinYear/KCalenMinMonth/KCalenMinDay.
       
    49      * Min/Max day is defined agenda server.
       
    50      * @param aTime aTime to be checked
       
    51      * @return EFalse : Out of range
       
    52      */
       
    53     IMPORT_C static TBool IsValidDay( const TTime& aTime );
       
    54 
       
    55     /**
       
    56      * Gets range from aStartDay @ 0:00 -> aEndDay @ 23:59
       
    57      * @param aStartDay Day for the range start.
       
    58      * @param aEndDay Day for the range end.
       
    59      * @param aRange The range is returned here.
       
    60      */
       
    61     IMPORT_C static void GetDayRangeL( const TTime& aStartDay,
       
    62                                        const TTime& aEndDay,
       
    63                                        CalCommon::TCalTimeRange& aRange );
       
    64 
       
    65     /**
       
    66      * Return ETrue if aTime is NULL
       
    67      * @param aTime time to be compared against NULL time
       
    68      */
       
    69     IMPORT_C static TBool IsNullTimeL( TCalTime& aTime );
       
    70 
       
    71     /**
       
    72      * Return Min or Max time if aTime goes out of bounds. 
       
    73      * Valid range is [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime]
       
    74      * @param aTime time to be checked
       
    75      * @return aTime, if aTime in [CalenDateUtils::MinTime(), CalenDateUtils::MaxTime]
       
    76      *         CalenDateUtils::MinTime(), if aTime < CalenDateUtils::MinTime()
       
    77      *         CalenDateUtils::MaxTime(), if aTime > CalenDateUtils::MaxTime()
       
    78      */
       
    79     IMPORT_C static TTime LimitToValidTime( const TTime& aTime );
       
    80 
       
    81     /**
       
    82      * Return maximum allowed time. (31.
       
    83      */
       
    84     IMPORT_C static TTime MaxTime();
       
    85 
       
    86     /**
       
    87      * Return minimum allowed time.
       
    88      */
       
    89     IMPORT_C static TTime MinTime();
       
    90 
       
    91     /**
       
    92      * Return time of day as a minutes from midnight. Useful to get hours::minutes component of datetime, 
       
    93      * regardless of date
       
    94      */
       
    95     IMPORT_C static TTimeIntervalMinutes TimeOfDay( const TTime& aDateTime );
       
    96 
       
    97     /**
       
    98      * Round TTime to previous full hour, e.g. RoundToPreviousHour( 23.11.2006 9:31 ) = 23.11.2006 9:00
       
    99      */
       
   100     IMPORT_C static TTime RoundToPreviousHour( const TTime& aTime );
       
   101 
       
   102     /**
       
   103      * Round TTimeIntervalMinutes to previous full hour, e.g. RoundToPreviousHour( 130 min ) = 120 min
       
   104      */
       
   105     IMPORT_C static TTimeIntervalMinutes RoundToPreviousHour( const TTimeIntervalMinutes& aMinutes );
       
   106     
       
   107 
       
   108     /**
       
   109      * @return current time. 
       
   110      */ 
       
   111     IMPORT_C static TTime Now();
       
   112     
       
   113     /**
       
   114      * @return today with time component set to 00:00. 
       
   115      */ 
       
   116     IMPORT_C static TTime Today();
       
   117 
       
   118     /**
       
   119      * @return ETrue if given aTime is on today, EFalse otherwise
       
   120      */     
       
   121     IMPORT_C static TBool IsOnToday( const TTime& aTime );
       
   122 
       
   123     /* 
       
   124      * Given aDate = DD::MM::YY @ hh:mm:ss, it returns a TTime obj DD::MM::YY @ 08:00 am
       
   125      * @param: aDate, which has the DD::MM::YY
       
   126      */
       
   127     IMPORT_C static TTime DefaultTime( const TTime& aDate );
       
   128     
       
   129    
       
   130 private:
       
   131     // Hiding constructor, because this is static utility class.
       
   132     //lint -e{1526} 
       
   133     CalenDateUtils();
       
   134 
       
   135     // Hiding assignment, because this is static utility class.
       
   136     //lint -e{1526} 
       
   137     CalenDateUtils& operator=( const CalenDateUtils& );
       
   138 
       
   139     };
       
   140 
       
   141 #endif // __CALENDATEUTILS_H__
       
   142 
       
   143 
       
   144 // End of File