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

Konrad Rosenbaum konrad at silmor.de
Fri May 13 23:15:47 CEST 2011


On Friday 13 May 2011, John Layt wrote:
> The general sort of areas we are looking at include:
> * More formatting options
> * More date maths
> * Proper timezone support
> * Alternative calendar systems (Hebrew, Islamic, etc)

Before wishlists grow too long, a word or two of warning. This can get 
extremely complex.

On the time front: 

according to Wikipedia there are 25 nautical time zones. Which are 
universally ignored by anyone, but sailors. In the latter case I seem to 
remember that the captain of the ship decides whether and when to change 
time zones while traveling the oceans.

Also according to WP we currently have 39 actually used time zones. There 
are probably more. Olson DB lists 434 zone definitions (quite a few are 
duplicates, but it is still impressive).

From time to time leap seconds are inserted into time. Regularly, because 
earth does not spin exactly once in 24 hours. It is slightly slower. To make 
matters worse, there are irregular leap seconds because earth is as confused 
about time as its inhabitants - some events (like big tsunamis and major 
quakes) can slightly shift earths axis. Fortunately most computers ignore 
leap seconds. Fortunately, because it makes a programmers life easier.

If you take daylight saving time (and similar concepts) into account (which 
you have to) you have to shift by one hour (or sometimes other values) twice 
per year. The definition on when this shift happens can follow complex rules 
(there are three algorithmic variants in POSIX). Although many politicians 
are not very good at keeping within their allotted speaking time, they often 
have a firm opinion about time zones and tend to introduce changes to them 
randomly (Olson DB is updated at least once per month, often with multiple 
changes).

Complicated enough yet? It gets better!

If you take history beyond a certain point, it gets really complex. Just to 
speak from my own little corner of the planet: today Germany has just one 
time zone definition, which has changed about a dozen times in the 20th 
century; before 1800 Germany was split into several independent states (once 
upon a time there were 300 mini states) - each one having its own definition 
of time. Good luck with researching their definitions and historic changes.

On the date front:

The western calender system (back then Julian) went into effect around the 
year 300. The start of it was miscalculated and subsequently redefined of 
course. It changed its definition of days of the year around 1582 and made a 
nice little jump to correct for past inaccuracies (the Julian to Gregorian 
shift). Of course every country did introduce the change at a different time 
- the last European one was Greece in 1923, only 341 years late (remember 
the many states that are today called "Germany" - yes they introduced the 
Gregorian calendar at different times too, not even talking about the rest 
of Europe and the world).

There are 23 calendar systems listed on Wikipedia (special systems for 
astronomers and other sciences aren't even in this list). I haven't 
researched them, but I'm quite sure they have similar corrections that make 
things "interesting".

There are systems that use different weeks. Or no week at all. Some historic 
calendars had days that were unnumbered (e.g. the Roman ides - days in the 
middle of months that have 31 days and were considered unlucky; proof: 
Julius Caesar was killed during the ides of March).

Even more historically calendars used to either not exist or change with 
every new regent ("during the rainy season in the year 15 of pharao Ramses 
II it came to pass..."). Good luck with researching on what date Ramses II 
was born and whether the rainy season was early or late during his 15th year 
of regency - I don't think it is settled yet (maybe he didn't know it 
himself)... ;-)


To make a complicated story short: it is possible to adapt to one or two 
systems that are widely used by computers to calculate local system time. I 
myself did an adaptation of the Olson DB for Qt[1]. It is however a 
tremendous undertaking to support all possibilities in Qt. I would estimate 
the (continuing) effort higher than rewriting Qt itself.

[1] http://silmor.de/77


	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110513/0fc61544/attachment.bin 


More information about the Qt-interest-old mailing list