System Time Zone Information

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

 

I needed time zone adjustment information for a current project, so decided to write a separate program to explore what is available.  Since we identify our time zone to  Windows at installation time and since it politely asks us to confirm when when it changes the clock for daylight savings time, it seems logical that the information would be available.  Sure enough Windows API function GetTimeZoneInformation returns a record, TTimeZoneInformation,  with everything you would want to know; Specifically:

bulletBias - the offset in minutes to add to local time  to get UTC (Universal Time Coordinated, also/formerly known as GMT, Greenwich Mean Time).  
bulletTime zone name
bulletDaylight savings name
bulletDate and time for start of Daylight savings time
bulletDate and time for end of Daylight savings time
bulletDaylight savings time adjustment amount

The function also returns an integer result indicating:

bulletInformation not available
bulletWe are in daylight savings time
bulletWe are not in daylight savings time

Delphi provides both the hook to the function and the record definition.  Here is a simple program that just calls GetTimeZoneInformation  and displays the results.

March 8, 2015:  A Delphi programmer in Europe recently reported that the start and end dates for Daylight Saving Time (DST) displayed by the program were incorrect.  I ran the program here and, sure enough, the results for EST here in the states was also incorrect and probably have been since 2004.   It turns out that those DST fields are actually "templates" describing the the Month, DayOfWeek(DOW) and a DayOfMonth field which actually specifies which occurrence of the DOW within the month defines the start and end dates.  E.g. "2nd Sunday in March" or "5th (or last) Sunday in October).   Version 2 posted today converts that DOW enumeration into an actual Day of Month value and the displays now show proper values, at least for USA and Europe.   

February 14, 2016:  Well, Aussies always like to break the mold and do things differently.  They did it again with Daylight Saving Time calculations:  Version 2.1 fixes two problem uncovered by a Brisbane programmer when he reported the demo program crashing.  It's difficult for me to test here, but I did recall that Windows DST information records only report Month of Year (MOY), Day of Week and Day of Month fields.  When  ending MOY is less than starting MOY, it's up the programmer to increment to the correct ending year value.   When that change didn't fix the user's crash problem, further checking uncovered that some Australian states including Queensland does not have any DST at all and Window record contains all zeros.  The program should now report correct end dates for Southern Hemisphere regions and "no DST for this location" instead of crashing when there is none.   Changes have not been tested, but someone down under will surely let me know if  problems still exist.             

Download source

Download executable

Created: January 25, 2004

Modified: May 12, 2018

 

 

 

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.