[Qt-interest] How calculate time span (days, hours, minutes) QDateTime difference?

Sean Harmer sean.harmer at maps-technology.com
Fri Jun 11 20:32:46 CEST 2010


Hi,

On Friday 11 June 2010 19:09:16 Jason H wrote:
> Having a TimeSpan class would be wonderful. I've used the MS one with great
> success and appreciation.
> 
> Qt's date/time handling has been horrendous, but getting better. Please
> also note timezone issues. As we become a more interconnected net society,
> we need to be able to translate dates/times across timezone/date
> boundaries. This effects Q[Date][Time] edits as well. The "universal" fix
> is to store everything in UTC, then convert to local time zones.

Yeah that should not be a problem. QDateTime is aware of local-time vs UTC.

> As for how that applies, you should get a 1 hour difference between
> 12:00am(-5UTC) and 12:00am(-4 UTC). Also, note that not all timezones are
> on hour boundaries. Also, UTC!=GMT, GMT observes daylight savings....

No worries, I live in the UK and have two small children so I am familiar with 
the chaos that daylight savings time causes - try explaining why they should 
go back to sleep to a 2 year old when the clocks change ;-)

I'll see what I can do but my time is quite limited at the moment. I'll post 
back again when I get something into a usable state on gitorious.

Have a good weekend,

Sean



More information about the Qt-interest-old mailing list