calendarui/commonutils/src/calenagendautils.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 14:57:40 +0300
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 45 b6db4fd4947b
permissions -rw-r--r--
Revision: 201011 Kit: 201015

/*
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Static utility functions. 
 *                - date utils to help comparisions and calculations with
 *                  dates and times. 
 *
*/


//INCLUDE FILES
#include <QList>
#include <QDateTime>

#include "calendarui_debug.h"
#include "calenagendautils.h"
#include "calendateutils.h"

// ============================ MEMBER FUNCTIONS ==============================
// ============================ CalenAgendaUtils ==============================

// -----------------------------------------------------------------------------
// CalenAgendaUtils::RemoveEntriesStartingAtMidnight
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
 void CalenAgendaUtils::removeEntriesEndingAtMidnightL( QList<AgendaEntry>& list, 
                                                                const QDateTime& day )
    {
    TRACE_ENTRY_POINT;

    // Remove events starting before aDay and ending at midnight
    TInt i( 0 );

    while( i < list.count() )
        {
        AgendaEntry& entry = list[i];

        if( endsAtStartOfDayL( entry, day ) )
            {
            list.removeAt( i );
            }
        else
            {
            ++i;
            }
        }
    
    TRACE_EXIT_POINT;
    }

// -----------------------------------------------------------------------------
// CalenAgendaUtils::EndsAtStartOfDayL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
 bool CalenAgendaUtils::endsAtStartOfDayL( AgendaEntry& entry,
                                          const QDateTime& day )
    {
    TRACE_ENTRY_POINT;
    
    const QDateTime dayStart = CalenDateUtils::beginningOfDay( day );
    const QDateTime startTime( entry.startTime() );
    const QDateTime endTime( entry.endTime() );

    const TBool result( endTime > startTime && endTime == dayStart );

    TRACE_EXIT_POINT;
    return result;
    }

//  End of File