On Tue, 20 Apr 2010 15:12:43 +0100, Jugdish <jugd...@gmail.com> wrote:
> I'm trying to format Python datetime objects into strings using QLocale,
> but
> it seems that under SIP API v2, the time information is lost? Are
datetime
> objects being interpreted as QDate rather than QDateTime? Here's an
> example:
> 
> #################
> # API v1
> #################
> from PyQt4.QtCore import *
> locale = QLocale()
> locale.toString(QDateTime.currentDateTime(), locale.dateTimeFormat())
> # returns PyQt4.QtCore.QString(u'Tuesday, 20 April 2010 15:06:19 ')
> 
> #################
> # API v2
> #################
> import sip
> sip.setapi("QString", 2)
> sip.setapi("QDate", 2)
> sip.setapi("QDateTime", 2)
> sip.setapi("QTime", 2)
> from PyQt4.QtCore import *
> import datetime
> locale = QLocale()
> locale.toString(datetime.datetime.now(), locale.dateTimeFormat())
> # returns u'Tuesday, 20 April 2010 HH:mm:ss '

It's nothing to do with the API version (that only affects __hash__()),
it's a bug in QLocale. Fixed in tonight's snapshot.

Thanks,
Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to