Where in the world?
When dealing with individuals in different time zones it is not always easy to keep track of ‘their’ local time. Many know the time zone bias for the popular world time zones but what about those not so well known places? In an effort to prevent the need to do some quick calculations I decided I’d write a little utility (desktop clock that will be added to the Freeware section someday soon) to display multiple time zone times. Question:With the idea in mind, how does one get a list of time zones and calculate the bias?
Answer: MSDN is your friend! I found a nice article on Retrieving Time-Zone Information. The article explains where and how the time zone information is stored. The TIME_ZONE_INFORMATION structure contains a Bias, StandardBias and DaylightBias to assist in the calculating of the time in a selected time zone.
For the following quick code I had placed a TComboBox and a TMemo on a TForm. When the form is shown the available time zones are added to the TComoBox.Items. When a time zone is selected pieces of information are displayed in the TMemo. For this I used BDS2006.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Memo1: TMemo;
procedure ComboBox1Change(Sender: TObject);
procedure FormShow(Sender: TObject);
public
procedure FillComboBox(combobox: TComboBox);
procedure FillMemo(timezone: string; memo: TMemo);
end;
var
Form1: TForm1;
implementation
uses
Registry;
{$R *.dfm}
{ TForm1 }
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if Sender is TComboBox then
FillMemo(TComboBox(Sender).Text,Memo1);
end;
procedure TForm1.FillComboBox(combobox: TComboBox);
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_READ);
combobox.Items.BeginUpdate;
try
comboBox.Items.Clear;
reg.RootKey:= HKEY_LOCAL_MACHINE;
if reg.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones',False) then
reg.GetKeyNames(combobox.Items);
finally
reg.Free;
combobox.Items.EndUpdate;
end;
end;
procedure TForm1.FillMemo(timezone: string; memo: TMemo);
var
reg: TRegistry;
regkey: string;
tzi: TTimeZoneInformation;
begin
memo.Lines.Clear;
reg:= TRegistry.Create(KEY_READ);
regkey:= Format('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\%s',[timezone]);
try
reg.RootKey:= HKEY_LOCAL_MACHINE;
if reg.OpenKey(regkey,False) then
begin
memo.Lines.Add(Format('Daylight Time Display: %s',[reg.ReadString('Dlt')]));
memo.Lines.Add(Format('Standard Time Display: %s',[reg.ReadString('Std')]));
reg.ReadBinaryData('TZI',tzi,sizeof(tzi));
memo.Lines.Add(Format('Bias: %d minutes',[tzi.Bias]));
end;
finally
reg.Free;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
FillComboBox(ComboBox1);
end;
end.
Remember SWAG?
I generally only like to post once a day; I was searching through the internet and came across a bit of nostalgia - http://gdsoft.com/swag/swag.html (formed from http://www.bsdg.org/SWAG/index.html) and couldn’t resist. Talk about a walk down memory lane (there are a few familiar names found in there). This brought me back to a time when newgroups consisted of FIDO feeds passed through BBS’ (I ran a two connection Synchronet BBS) that you connected to through a screamin’ dial-up modem. Back in the days of Turbo Pascal and the excitement of buying 4MB of RAM for $200+. I remember the night I upgraded from Windows® 3.1 to Windows® 95 like it was yesterday. It is amazing how times change and how fast things progress.
Adieu George!
Some years ago, on a trip to the city, I stopped at a corner market for breakfast. I ordered my breakfast sandwich and provided payment to the cashier. The cashier handed back change consisting of both bills and coins. One of the bills had a strange stamp that caught my attention. The stamp referred to an interesting website address. Being of the curious type I decided to view the page while I consumed my morning fuel.
The site -- Where's George?! ®. This site allows you to track where your paper money has been and where it goes. This site only tracks US currency and has a brother, Where's Willy?! ®, for Canadian bills. I haven’t come across one for the Euro (does one exist?), but I could see how that would allow for more participation and interesting travel routes.
The Where's George?! ® site reminds me of something I had done back when I was in elementary school. I tool a ledger book and jotted down the numbers of the dollar bills that crossed my path in an attempt to see if I ever encountered the same bill twice. I never did come across a repeat visitor and the task became arduous to do by hand and ledger book so it was short lived. I wish I had something like this back then.
What's your George score?