~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kalarm/lib/datetime.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  datetime.cpp  -  date/time with start-of-day time for date-only values 
3
 
 *  Program:  kalarm
4
 
 *  Copyright © 2003,2005-2007,2009 by David Jarvie <djarvie@kde.org>
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License along
17
 
 *  with this program; if not, write to the Free Software Foundation, Inc.,
18
 
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 
 */
20
 
#include "kalarm.h"   //krazy:exclude=includes (kalarm.h must be first)
21
 
#include "datetime.h"
22
 
 
23
 
#include <kglobal.h>
24
 
#include <klocale.h>
25
 
 
26
 
 
27
 
QTime DateTime::mStartOfDay;
28
 
 
29
 
QTime DateTime::effectiveTime() const
30
 
{
31
 
        return mDateTime.isDateOnly() ? mStartOfDay : mDateTime.time();
32
 
}
33
 
 
34
 
QDateTime DateTime::effectiveDateTime() const
35
 
{
36
 
        if (mDateTime.isDateOnly())
37
 
        {
38
 
                QDateTime dt = mDateTime.dateTime();    // preserve Qt::UTC or Qt::LocalTime
39
 
                dt.setTime(mStartOfDay);
40
 
                return dt;
41
 
        }
42
 
        return mDateTime.dateTime();
43
 
}
44
 
 
45
 
KDateTime DateTime::effectiveKDateTime() const
46
 
{
47
 
        if (mDateTime.isDateOnly())
48
 
        {
49
 
                KDateTime dt = mDateTime;
50
 
                dt.setTime(mStartOfDay);
51
 
                return dt;
52
 
        }
53
 
        return mDateTime;
54
 
}
55
 
 
56
 
KDateTime DateTime::calendarKDateTime() const
57
 
{
58
 
        if (mDateTime.isDateOnly())
59
 
        {
60
 
                KDateTime dt = mDateTime;
61
 
                dt.setTime(QTime(0, 0));
62
 
                return dt;
63
 
        }
64
 
        return mDateTime;
65
 
}
66
 
 
67
 
QString DateTime::formatLocale(bool shortFormat) const
68
 
{
69
 
        return KGlobal::locale()->formatDateTime(mDateTime, (shortFormat ? KLocale::ShortDate : KLocale::LongDate));
70
 
}