Mega Code Archive

 
Categories / Delphi / Examples
 

Time is the simplest thing

...not! Primoz Gabrijelcic has been researching the different time systems used throughout the world and constructing a library of routines for converting between them. There are too many times. There is Greenwich Time and Military Time and Pacific Standard Time and Co-ordinated Universal Time and Central European Time and Local Time and System Time and Swatch Internet Time and Too Late Time, to mention just a few of them. And it is a royal pain in the you-know-where to convert between them. When you think you have sorted it out, somebody (usually not your friend, at least not after his remark) reminds you of Daylight Saving Time and your beautiful solution just falls apart. That happened to me, of course. I tried to write a simple routine that could convert a whole bunch of TDateTimes from local time to some more stable time base that doesn’t make wild jumps twice a year. After two hours browsing MSDN and the internet, I was no closer to a solution. Apparently, Windows does not have this function, nobody on the internet has this function, and nobody cares about this function. Even more, I was hopelessly lost in the world of UTC, GMT, TZ, +0200, and similar stuff. I dare you: do you know what a leap second is? No? Well, neither did I.