From af411746b1480e7b331ea7d163f39d2507cf7264 Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 16 Sep 2004 23:05:56 +0000 Subject: Fixed timezone problems in ompi --- (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index c3a1627..d99c6a3 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -27,7 +27,7 @@ Genericwrapper::~Genericwrapper() } cleanMimeCache(); } -QString Genericwrapper::parseDateTime( mailimf_date_time *date ) +const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) { static bool init = false ; if ( ! init ) { @@ -51,15 +51,23 @@ QString Genericwrapper::parseDateTime( mailimf_date_time *date ) QDate da (date->dt_year,date->dt_month, date->dt_day ); QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); QDateTime dt ( da ,ti ); + int addsec = -date->dt_zone*36; + //qDebug("adsec1 %d ",addsec ); + dt = dt.addSecs( addsec ); int off = KGlobal::locale()->localTimeOffset( dt ); - //dt = dt.addSecs( off*60 ); + //qDebug("adsec2 %d ",off*60 ); + + dt = dt.addSecs( off*60 ); + return dt; +#if 0 QString ret; - if ( da == QDate::currentDate () ) - ret = KGlobal::locale()->formatTime( ti,true); + if ( dt.date() == QDate::currentDate () ) + ret = KGlobal::locale()->formatTime( dt.time(),true); else { ret = KGlobal::locale()->formatDateTime( dt,true,true); } +#endif #if 0 if ( off < 0 ) ret += " -"; @@ -79,7 +87,7 @@ QString Genericwrapper::parseDateTime( mailimf_date_time *date ) return QString( tmp ); #endif - return ret; + //return ret; } void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) @@ -495,11 +503,18 @@ void Genericwrapper::parseList(QValueList > & if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); if (single_fields.fld_orig_date) { - mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); - char tmp[23]; - struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; - snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", - date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); + QString ret; + if ( dt.date() == QDate::currentDate () ) + ret = KGlobal::locale()->formatTime( dt.time(),true); + else { + ret = KGlobal::locale()->formatDateTime( dt,true,true); + } + mail->setDate( ret ); + char tmp[20]; + snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", + dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); + //qDebug(" iso %s ", tmp); mail->setIsoDate( QString( tmp ) ); } // crashes when accessing pop3 account? -- cgit v0.9.0.2