A time zone, is a region of the earth that has the same standard time. All areas within that region will apply the same time. Because earth sphere shape, and the rotation of the earth, generally there are 24 regions with each region has a difference of 1 hour. But some occasions appeared in some areas resulting it has different time from it region should have.
Windows Time Zone
If you set your time, you will see a time zone tab in the dialog. Alternatively, you can see windows standard time zones in regional setting in control panel. In that dialog, you'll see a list of standard time zones. Our primary goal in this article, is to retrieve the values and mimic it's functionality. And since I'm not lived in Daylight Saving countries, I'll skip that feature because I'm still don't know exactly how it work.
Preparation
Our first preparation is to know where Windows store this time zone list. It stored on registry, at "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\". In that key, there are many sub keys which provide information on each time zones. So, to retrieve the time zone list, we will look at these sub keys and read their values.
Designing Basic Fundamentals
The first time we should do is creating a Time Zone structure that will contain time zone data. We don't need a class because it's only for displaying data and light processing. Besides, we will use generic collection to store all time zones structure.
Code |
|
Next, we will analyze how time zone structures in registry where windows stored them. As I told earlier, windows stored time zone data in "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\". Each time zone data stored on a sub key. In sub key, there are 4 string values, a dword values and a binary values. Basically, we need only one key which is display values. The display key will be added in our time zone structures. From this display data, we will set time span for the time zone as well. To validate a time zone's time span, we will parse directly from display value. Display value will have data like this : "(GMT+07:00) Bangkok, Hanoi, Jakarta". In order to get time span, we will parse "(GMT+07:00)" in order to get 07:00 value. A new function will needed to parse this information, so we add it in Time Zone structure.
Code |
|
Now our base structure is ready to use. It's time to implement it in our class. For this sample, I'll use a form and a combo box for generate time zones.
First step is to initialize a collection variable that contain time zones. Next we will fill the collection to our list from windows registry. To access registry, we will need Win32 library.
Code |
|
Now we have our list fill with Time Zones information. Unfortunately, the list is not ordered like it should have. Also, time zone ordering is not based on alphabetical. It ordered by time span. Since standard collection class doesn't provide us with that kind of sorting, we have to make by our self.
Code |
|
That's all. Our Time Zone form is finished. The form will look like this.
Now, it can display as Windows Time Zone does. You can download the source sample here.
7 comments:
Yes undoubtedly, in some moments I can bruit about that I acquiesce in with you, but you may be considering other options.
to the article there is still a suspect as you did in the downgrade publication of this demand www.google.com/ie?as_q=detroitnewspapers.com\/payonline ?
I noticed the utter you have not used. Or you profit by the dreary methods of helping of the resource. I suffer with a week and do necheg
Wow, great code.. I love learning visual basic language than any other languages. I found your article very useful for me. Thanks for sharing it with us.
I think the admin of this site is really working hard
for his website, because here every stuff is quality based data.
Have a look at my blog post; 59377
Also see my web site :: http://mygang.sattvaq.com
І ԁon't know whether it's just me or if pеrhаps everyone else
еncountering problеms ωіth your sitе.
It lοoks lіke ѕome of thе written tеxt within youг роѕts are
гunning off the screеn. Cаn someone else pleaѕe proviԁe
feedbаck and let me know if thіs is
happеning to thеm as well? Thiѕ might be a iѕsue ωith mу browser bесausе
Ӏ've had this happen previously. Thanks
Visit my webpage: augenoperation
Howdy, i read your blog occasionally and i own a similar one and i was just curious if you get a
lot of spam comments? If so how do you protect against it, any plugin or anything you can suggest?
I get so much lately it's driving me crazy so any assistance is very much appreciated.
Feel free to surf to my website naedubeik.notlong.com
I ran acrοѕs this blog on httρ://vbcorner.
blоgѕpοt.cоm/ and іf І сould I'd like to suggest to you some useful things or ideas. Perhaps you can write your next articles referring to these ideas. I would like to read more things regarding what you'гe talking about.
Ηere is my ѕite - scatty
For more brilliance, use tiny white fairy lights inside fabric all the way up the posts and over the canopy with the chuppah.
charm bracelets are manufactured from solid bases that
can be made from several materials. Diamonds are forever so should be bought with utmost
care.
Take a look at my weblog - jewelry - -
Post a Comment