[Qt-interest] New Date and Time Features in Qt5?

David Ching dc at dcsoft.com
Thu Jun 2 02:49:17 CEST 2011


-----Original Message-----
Date: Tue, 31 May 2011 10:36:54 +0200
From: "Konrad Rosenbaum" <konrad at silmor.de>
Subject: Re: [Qt-interest] New Date and Time Features in Qt5?
To: qt-interest at qt.nokia.com
Message-ID:
	<31ebf7c1f5028610bc0614f342757bea.squirrel at squirrel.six.silmor.de>
Content-Type: text/plain;charset=iso-8859-1

>On Tue, May 31, 2011 07:56, David Ching wrote:
>> I could be writing a UI that shows the user their time zone and whether
or
>> not DST is in effect or not.
>
>>Ok, I could understand that some users are interested in this.
>
[snip]
>
>Hmm. This needs a clarification:
>
>UTC-7 or UTC+2 is NOT a timezone it is an offset. So during DST you should
>get a time zone of "Pacific Summer Time" with an offset of UTC-7. During
>standard "winter" time you should get a timezone of "Pacific Time" with
>offset UTC-8. You should never get "UTC-8" as a time zone (unless you are
>on a system that allows you to use "unusual" time zones and you do use
>them).

Yes, you are right.  What I really want for my UI is
QDateTime::currentTimeZone() which would return UTC-8, and also
QDateTime::dstOffset() which returns -60 (60 minutes) if DST is active, and
0 if DST is not active.

This leaves intact the current QDateTime usage of local time (reporting
UTC-8 if DST is not active, and UTC-7 if it is active) for the majority of
use cases when we do want DST to be automatically factored into the offset. 


> I have another case where I need to query the current UTC time (current
> QDateTime provides this OK) and also the offset in minutes of the local
> timezone compared to UTC.  This offset should not take into account DST
> (not
> possible in Qt now).

[snip]

>> These two info is sent via serial port to FTDI chip
>> on
>> a USB device to set its current time.  It tracks DST itself and applies
>> it,
>> that's why the offset I send should not include DST.
>
>This sounds broken by design. If the device was designed to work only in
>your time zone: you can still hard code the offsets. If not: complain to
>the manufacturer.
>
>If you can change the firmware: I recommend to either make the device time
>zone agnostic and let it track UTC (measurement or logging device) or make
>it track local time without automatic DST changes (a display clock).

The device is a wristwatch whose time is set by the PC.  However, it records
various things and this data is timestamped and uploaded to a web server.
So the watch needs to display local time, but the data needs to be
timestamped to UTC time.  You are right, I can send it both UTC time, and an
offset and let it calculate local time.  It doesn't need to know about
timezone or DST.  I'll work with the firmware team on this and write back if
they have any points that I'm missing. 

Thanks,
David




More information about the Qt-interest-old mailing list