2
* datetime.cpp - date/time with start-of-day time for date-only values
4
* Copyright © 2003,2005-2007,2009 by David Jarvie <djarvie@kde.org>
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.
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.
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.
20
#include "kalarm.h" //krazy:exclude=includes (kalarm.h must be first)
27
QTime DateTime::mStartOfDay;
29
QTime DateTime::effectiveTime() const
31
return mDateTime.isDateOnly() ? mStartOfDay : mDateTime.time();
34
QDateTime DateTime::effectiveDateTime() const
36
if (mDateTime.isDateOnly())
38
QDateTime dt = mDateTime.dateTime(); // preserve Qt::UTC or Qt::LocalTime
39
dt.setTime(mStartOfDay);
42
return mDateTime.dateTime();
45
KDateTime DateTime::effectiveKDateTime() const
47
if (mDateTime.isDateOnly())
49
KDateTime dt = mDateTime;
50
dt.setTime(mStartOfDay);
56
KDateTime DateTime::calendarKDateTime() const
58
if (mDateTime.isDateOnly())
60
KDateTime dt = mDateTime;
61
dt.setTime(QTime(0, 0));
67
QString DateTime::formatLocale(bool shortFormat) const
69
return KGlobal::locale()->formatDateTime(mDateTime, (shortFormat ? KLocale::ShortDate : KLocale::LongDate));