I'm always caught off guard when that fateful Sunday rolls around when time either springs ahead or falls back an hour. The hour backward in fall isn't so bad. Although it still sneaks up on me, I don't mind having an extra hour to sleep or just relax. But that Sunday in early spring when I have to get up an hour earlier is a killer.
To make these new dates less of a rude awakening, I wrote a script named GetDLSDates.vbs. By simply double-clicking the script, I get a reminder of when daylight saving time begins and ends in the current year. Without having to change any code, this script will work the same year after year, even given the upcoming changes in daylight saving time. (For information about these changes, see the sidebar "Daylight Saving Time Is Changing in 2007.")
GetDLSDates.vbs uses Windows Management Instrumentation's (WMI's) Win32_TimeZone class to access information about the time zone and daylight saving time properties in a Windows OS. Thus, to understand how the script works, you need to know what several Win32_TimeZone class properties represent.
The Win32_TimeZone Class Properties
GetDLSDates.vbs relies on the following Win32_TimeZone class properties:
- Bias. The Bias property represents the difference in minutes between Greenwich Mean Time (GMT—also known as Coordinated Universal Time, or UTC) and local time. For example, Eastern time (US and Canada) has a Bias property value of -300. You can also find the bias represented in hours instead of minutes. For example, Windows' Date and Time Properties dialog box shows the bias between Eastern time and GMT as -05:00, which means GMT minus 5 hours.
- DaylightBias. The DaylightBias property is the offset value used when the Windows clock is set to automatically adjust for daylight saving time. In the Win32_Time-Zone class documentation, Microsoft states that the DaylightBias property value is added to the Bias property value to form the bias used during daylight saving time. The term "added" can be confusing. In most time zones, the DaylightBias property has a value of -60 minutes. If you add the DaylightBias property value to the Bias property value, you'll get a wrong value, such as
-300 + -60 = -360
However, if you subtract the DaylightBias property value from the Bias property value, you get the correct value
-300 - -60 = -240
because the double negative translates into a positive number:
-300 +60 = -240
In this sense, you could say that you're adding the DaylightBias value to the Bias value.
- StandardBias. The StandardBias property is used to determine the bias when daylight saving time isn't in effect. It typically has the value of 0.
- DaylightMonth and Standard-Month. The DaylightMonth property represents the month in which daylight saving time starts, whereas the StandardMonth property represents the month in which daylight saving time ends. The possible values for both properties range from 1 to 12 and represent the corresponding months of the year. For example, when daylight saving time begins in April, the Daylight-Month property has a value of 4. When daylight saving time ends in October, the StandardMonth property has a value of 10.
- DaylightDayOfWeek and Standard-DayOfWeek. The DaylightDay-OfWeek property represents the day of the week when daylight saving time starts. Its counterpart, StandardDayOfWeek, represents the day of the week when daylight saving time ends. The possible value ranges for both properties are 0 through 6, with 0 representing Sunday and 6 representing Saturday. Typically, both values are set to 0 (Sunday).
- DaylightDay and StandardDay. The DaylightDay property represents the first (value of 1), second (2), third (3), fourth (4), or fifth (5) occurrence of the day specified by DaylightDayOfWeek. The Standard-Day property has the same usage and values as DaylightDay, except it indicates the first, second, third, fourth, or fifth occurrence of StandardDayOfWeek. So, for example, when daylight saving time begins on the first Sunday of April, the DaylightDay property would have a value of 1. When daylight saving time ends the last Sunday of October, the StandardDay property would have a value of 4 or 5, depending on when October 1 falls. For example, this year October 1 fell on a Sunday, so the last Sunday of the month is the fifth occurrence (i.e., StandardDay = 5).
- DaylightHour and StandardHour. The DaylightHour and Standard-Hour properties specify the hour of the day that daylight saving time begins and ends, respectively. In most cases, these property values are set to the value 2, which represents 2 A.M.
- DaylightMinute and Standard-Minute. The DaylightMinute and StandardMinute properties specify the minute of the day that daylight saving time begins and ends, respectively. In most cases, these property values are set to the value of 0.
- DaylightName and StandardName. The DaylightName property contains a string value that specifies the time-zone name when daylight saving time is in effect (e.g., Eastern Daylight Time). The StandardName property's string value specifies the time-zone name when daylight saving time isn't in effect (e.g., Eastern Standard Time).
Now that you know about the importantWin32_TimeZone class properties, let's take a look at how GetDLSDates-.vbs uses them.