Diffstat (limited to 'library/backend/timeconversion.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | library/backend/timeconversion.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/backend/timeconversion.cpp b/library/backend/timeconversion.cpp index df7b0d5..6551697 100644 --- a/library/backend/timeconversion.cpp +++ b/library/backend/timeconversion.cpp @@ -1,92 +1,92 @@ /**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qglobal.h>
#include <qtopia/timeconversion.h>
#include <qregexp.h>
#include <stdlib.h>
QString TimeConversion::toString( const QDate &d )
{
- QString empty;
- if ( d.isNull() )
- return empty;
+// QString empty;
+// if ( d.isNull() )
+// return empty;
QString r = QString::number( d.day() ) + "." +
QString::number( d.month() ) + "." +
QString::number( d.year() );
//qDebug("TimeConversion::toString %s", r.latin1());
return r;
}
QDate TimeConversion::fromString( const QString &datestr )
{
- QDate empty;
- if ( datestr.isEmpty() )
- return empty;
+// QDate empty;
+// if ( datestr.isEmpty() )
+// return empty;
int monthPos = datestr.find('.');
int yearPos = datestr.find('.', monthPos+1 );
if ( monthPos == -1 || yearPos == -1 ) {
qDebug("fromString didn't find . in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, yearPos );
return QDate();
}
int d = datestr.left( monthPos ).toInt();
int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt();
int y = datestr.mid( yearPos+1 ).toInt();
QDate date ( y,m,d );
//qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, yearPos);
return date;
}
time_t TimeConversion::toUTC( const QDateTime& dt )
{
time_t tmp;
struct tm *lt;
#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64)
_tzset();
#else
tzset();
#endif
// get a tm structure from the system to get the correct tz_name
tmp = time( 0 );
lt = localtime( &tmp );
lt->tm_sec = dt.time().second();
lt->tm_min = dt.time().minute();
lt->tm_hour = dt.time().hour();
lt->tm_mday = dt.date().day();
lt->tm_mon = dt.date().month() - 1; // 0-11 instead of 1-12
lt->tm_year = dt.date().year() - 1900; // year - 1900
//lt->tm_wday = dt.date().dayOfWeek(); ignored anyway
//lt->tm_yday = dt.date().dayOfYear(); ignored anyway
lt->tm_wday = -1;
lt->tm_yday = -1;
// tm_isdst negative -> mktime will find out about DST
lt->tm_isdst = -1;
// keep tm_zone and tm_gmtoff
tmp = mktime( lt );
return tmp;
}
QDateTime TimeConversion::fromUTC( time_t time )
|