summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/oconversion.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/oconversion.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/oconversion.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/oconversion.cpp
index 0d15414..b7eebef 100644
--- a/libopie2/opiepim/core/oconversion.cpp
+++ b/libopie2/opiepim/core/oconversion.cpp
@@ -1,29 +1,47 @@
1/********************************************************************** 1/*
2** Copyright (C) 2003 by Stefan Eilers (eilers.stefan@epost.de) 2 This file is part of the Opie Project
3** 3 Copyright (C) The Main Author <main-author@whereever.org>
4** This file may be distributed and/or modified under the terms of the 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5** GNU Lesser General Public License version 2 as published by the Free Software 5 .=l.
6** Foundation and appearing in the file LICENSE.GPL included in the 6 .>+-=
7** packaging of this file. 7 _;:, .> :=|. This program is free software; you can
8** 8.> <`_, > . <= redistribute it and/or modify it under
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10.="- .-=="i, .._ License as published by the Free Software
11** 11 - . .-<_> .<> Foundation; either version 2 of the License,
12**********************************************************************/ 12 ._= =} : or (at your option) any later version.
13 13 .%`+i> _;_.
14#include "oconversion.h" 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#include <opie2/oconversion.h>
15#include <qpe/timeconversion.h> 31#include <qpe/timeconversion.h>
16 32
17 33
34namespace Opie {
35
18QString OConversion::dateToString( const QDate &d ) 36QString OConversion::dateToString( const QDate &d )
19{ 37{
20 if ( d.isNull() || !d.isValid() ) 38 if ( d.isNull() || !d.isValid() )
21 return QString::null; 39 return QString::null;
22 40
23 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 41 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
24 QString year = QString::number( d.year() ); 42 QString year = QString::number( d.year() );
25 QString month = QString::number( d.month() ); 43 QString month = QString::number( d.month() );
26 month = month.rightJustify( 2, '0' ); 44 month = month.rightJustify( 2, '0' );
27 QString day = QString::number( d.day() ); 45 QString day = QString::number( d.day() );
28 day = day.rightJustify( 2, '0' ); 46 day = day.rightJustify( 2, '0' );
29 47
@@ -102,12 +120,13 @@ QDateTime OConversion::dateTimeFromString( const QString& str) {
102 int month = str.mid(2, 2).toInt(); 120 int month = str.mid(2, 2).toInt();
103 int year = str.mid(4, 4).toInt(); 121 int year = str.mid(4, 4).toInt();
104 int hour = str.mid(8, 2).toInt(); 122 int hour = str.mid(8, 2).toInt();
105 int min = str.mid(10, 2).toInt(); 123 int min = str.mid(10, 2).toInt();
106 int sec = str.mid(12, 2).toInt(); 124 int sec = str.mid(12, 2).toInt();
107 125
108 QDate date( year, month, day ); 126 QDate date( year, month, day );
109 QTime time( hour, min, sec ); 127 QTime time( hour, min, sec );
110 QDateTime dt( date, time ); 128 QDateTime dt( date, time );
111 return dt; 129 return dt;
112} 130}
113 131
132} \ No newline at end of file