File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1157,6 +1157,29 @@ void QDateTime::setTime_t( uint secsSince1Jan1970UTC )
11571157}
11581158
11591159
1160+ /* !
1161+ Sets the UTC date and time given the number of seconds that have passed
1162+ since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
1163+
1164+ Note that Microsoft Windows supports only a limited range of values for
1165+ \a secsSince1Jan1970UTC.
1166+ */
1167+
1168+ void QDateTime::setTimeUtc_t ( uint secsSince1Jan1970UTC )
1169+ {
1170+ time_t tmp = (time_t ) secsSince1Jan1970UTC;
1171+ tm *tM = gmtime ( &tmp );
1172+ if ( !tM ) {
1173+ d.jd = QDate::greg2jul ( 1970 , 1 , 1 );
1174+ t.ds = 0 ;
1175+ return ;
1176+ }
1177+ d.jd = QDate::greg2jul ( tM->tm_year + 1900 , tM->tm_mon + 1 , tM->tm_mday );
1178+ t.ds = MSECS_PER_HOUR*tM->tm_hour + MSECS_PER_MIN*tM->tm_min +
1179+ 1000 *tM->tm_sec ;
1180+ }
1181+
1182+
11601183/* !
11611184 Returns the datetime as a string.
11621185
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class Q_EXPORT QDateTime
173173 void setDate ( const QDate &date ) { d=date; }
174174 void setTime ( const QTime &time ) { t=time; }
175175 void setTime_t ( uint secsSince1Jan1970UTC );
176+ void setTimeUtc_t ( uint secsSince1Jan1970UTC );
176177
177178 QString toString () const ;
178179
Original file line number Diff line number Diff line change @@ -2582,7 +2582,7 @@ QCString dateToString(bool includeTime)
25822582 }
25832583 else // all ok, replace current time with epoch value
25842584 {
2585- current.setTime_t ((ulong)epoch); // TODO: add support for 64bit epoch value
2585+ current.setTimeUtc_t ((ulong)epoch); // TODO: add support for 64bit epoch value
25862586 }
25872587 }
25882588 return theTranslator->trDateTime (current.date ().year (),
You can’t perform that action at this time.
0 commit comments