summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2002-09-24 13:37:32 (UTC)
committer zecke <zecke>2002-09-24 13:37:32 (UTC)
commit70328f952e475eb7eb0bc961420b875eefd05211 (patch) (unidiff)
treeb9270f878b00dd8f8d525a82897f984ba6f5a484 /library
parent5d29b14fc85d99d45a32fdaed27653c6f271a5ce (diff)
downloadopie-70328f952e475eb7eb0bc961420b875eefd05211.zip
opie-70328f952e475eb7eb0bc961420b875eefd05211.tar.gz
opie-70328f952e475eb7eb0bc961420b875eefd05211.tar.bz2
make thetime
not a pointer and memset it this makes valgrind shut up
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/timeconversion.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/library/backend/timeconversion.cpp b/library/backend/timeconversion.cpp
index ef7762d..3c25922 100644
--- a/library/backend/timeconversion.cpp
+++ b/library/backend/timeconversion.cpp
@@ -133,7 +133,7 @@ QDateTime TimeConversion::fromISO8601( const QCString &s )
133 tzset(); 133 tzset();
134#endif 134#endif
135 135
136 struct tm *thetime = new tm; 136 struct tm thetime;
137 137
138 QCString str = s.copy(); 138 QCString str = s.copy();
139 str.replace(QRegExp("-"), "" ); 139 str.replace(QRegExp("-"), "" );
@@ -152,23 +152,24 @@ QDateTime TimeConversion::fromISO8601( const QCString &s )
152 } 152 }
153 153
154// qDebug("--- parsing ISO time---"); 154// qDebug("--- parsing ISO time---");
155 thetime->tm_year = 100; 155 memset( &thetime, 0, sizeof(tm) );
156 thetime->tm_mon = 0; 156 thetime.tm_year = 100;
157 thetime->tm_mday = 0; 157 thetime.tm_mon = 0;
158 thetime->tm_hour = 0; 158 thetime.tm_mday = 0;
159 thetime->tm_min = 0; 159 thetime.tm_hour = 0;
160 thetime->tm_sec = 0; 160 thetime.tm_min = 0;
161 thetime.tm_sec = 0;
161 162
162// qDebug("date = %s", date.data() ); 163// qDebug("date = %s", date.data() );
163 164
164 switch( date.length() ) { 165 switch( date.length() ) {
165 case 8: 166 case 8:
166 thetime->tm_mday = date.right( 2 ).toInt(); 167 thetime.tm_mday = date.right( 2 ).toInt();
167 case 6: 168 case 6:
168 thetime->tm_mon = date.mid( 4, 2 ).toInt() - 1; 169 thetime.tm_mon = date.mid( 4, 2 ).toInt() - 1;
169 case 4: 170 case 4:
170 thetime->tm_year = date.left( 4 ).toInt(); 171 thetime.tm_year = date.left( 4 ).toInt();
171 thetime->tm_year -= 1900; 172 thetime.tm_year -= 1900;
172 break; 173 break;
173 default: 174 default:
174 break; 175 break;
@@ -206,11 +207,11 @@ QDateTime TimeConversion::fromISO8601( const QCString &s )
206 // get the time: 207 // get the time:
207 switch( timestr.length() ) { 208 switch( timestr.length() ) {
208 case 6: 209 case 6:
209 thetime->tm_sec = timestr.mid( 4 ).toInt(); 210 thetime.tm_sec = timestr.mid( 4 ).toInt();
210 case 4: 211 case 4:
211 thetime->tm_min = timestr.mid( 2, 2 ).toInt(); 212 thetime.tm_min = timestr.mid( 2, 2 ).toInt();
212 case 2: 213 case 2:
213 thetime->tm_hour = timestr.left( 2 ).toInt(); 214 thetime.tm_hour = timestr.left( 2 ).toInt();
214 default: 215 default:
215 break; 216 break;
216 } 217 }
@@ -227,10 +228,10 @@ QDateTime TimeConversion::fromISO8601( const QCString &s )
227// qDebug("time: %d %d %d, tzloc=%d, tzoff=%d", thetime->tm_hour, thetime->tm_min, thetime->tm_sec, 228// qDebug("time: %d %d %d, tzloc=%d, tzoff=%d", thetime->tm_hour, thetime->tm_min, thetime->tm_sec,
228 // tzloc, tzoff ); 229 // tzloc, tzoff );
229 230
230 tmp = mktime( thetime ); 231 tmp = mktime( &thetime );
231 tmp += 60*(-tzloc + tzoff); 232 tmp += 60*(-tzloc + tzoff);
232 233
233 delete thetime; 234
234 235
235 return fromUTC( tmp ); 236 return fromUTC( tmp );
236} 237}