On Monday 07 April 2008 10:24:15 AndrÃ PÃnitz wrote:
> > > Anyways, that explains why you got different values:
> > > 1) QDateTime applied the rules for Jan 1st 1970 for your June 1947
> > > date.
> 1947... well, there was a time when part of Germany had Moscow time.
> Not sure this bites here, but it's not unlikely.
I have reviewed the timezone database and there are really, really weird rules
When they are able, the database keepers try to record historical information
of the past, like double summer times observed in times of war. The database
also contains the very useless local mean time of the city, as well as the
leap second information. (December 31st, 23:59:60 and June 30th, 23:59:60,
In any case, there's one interesting rule: dates before 1970 and after 2037
are not keep strict. What matters is the 32-bit signed positive range of
I'll be making the following changes to fix this bug:
1) when the dates fall outside the range of 1970-01-01 and 2037-12-31, change
only the year to match the upper or lower limit, but keep the day and month
2) add some information to the documentation of QDateTime, specifically about
the Julian/Gregorian switch in 1582 and the fact that the timezone database
isn't precise for any date that isn't between 1970 and the present. And then
for Unix only, since Windows has no concept of timezone database.
It's interesting to note that the choice of new year's day for calculating the
GMT offset in QDateTime means there's a higher probability of being wrong
than being right. The Northern Hemisphere spends more than half of the year
in Summer Time and more than half of the world's population is in it. That
means that, for a given date, there's a higher probability that DST rules
should be applied instead of the official time.
For the Southern Hemisphere, it's the opposite: it spends less than half of
the year in Summer Time. But, of course, since New Year's Day is in Summer,
the probability that the offset wanted was the official time (instead of the
DST one) is greater.
Timekeeping for past dates is very, very uncertain.
The concept of organised timezones as we know today didn't exist more than 50
years ago. Many European countries before 1940 used local mean times: for
example, the Netherlands' official time was 20 minutes ahead of GMT; in the
UK, until 1900, the use of local mean time in each city was the rule.
Not only that, there's also the problem of the Gregorian/Julian switch, which
happened in different countries at different times. And there's the problem
of some countries tinkering with their calendars, like when Sweden decided to
have a February 30th in 1712.
And you thought Y2K was complicated :-)
Thiago JosÃ Macieira - thiago.macieira AT trolltech.com
Trolltech ASA - Sandakerveien 116, NO-0402 Oslo, Norway