VOICE Home Page: http://www.os2voice.org | August 2001 [Newsletter Index] [Previous Page] [Next Page] [Feature Index] editor@os2voice.org

##
Setting the System Clock to UTC

By Brian Crook © August 2001

The reason I started looking at this is because I do astronomy stuff and worldwide, astronomy uses UTC as a base. So I needed a solution that would allow me to run my system clock as UTC but still allow my clock to display local time.

#### The Ingredients

Below is an image that shows:

1. WorldClock running with times set correctly

2. SYSBAR clock which is 10 hours out

3. WorldClock settings window with the UTC option ticked

4. TIME868 window For more on Time868, click here.

I also tested three different TZ variables in config.sys. For those who want a bit more of an explanation on the TZ variable, click here

OK, the above are the ingredients, how I put them together?

## The Problem

I have been using TIME868 for years ( what a fine example of a stable program) and I did not want to lose the ability to keep my system clock accurate.

Unfortunately if you set the system clock to UTC then none of the display clocks will be correct (see the Sysbar clock).

Fortunately TIME868 reads the TZ variable in Config.sys which enables you to fudge things.

The first TZ variable is the 'normal' one: i.e. TIME868 reads it, works out the offset, which is the -10 then goes and gets the correct time, adjusts it for the offset and sets the system clock.
The daylight saving part says to set the clock forward one hour in October and back one hour in March.

> `REM LOCAL TIME WITH LOCAL D/SAVING
> REM SET TZ=EST-10EDT,10,-1,0,7200,3,-1,0,7200,3600
> `

The second TZ variable I tried is the GMT one, the offset is 0, with the daylight saving parameters set for London time. This worked but my display clocks were one hour out.

> `REM GMT WITH GMT D/SAVING
> REM SET TZ=BST0BDT,3,-1,0,7200,10,-1,0,10800,3600
> `

This worked but my display clocks were one hour out, obviously due to daylight saving. What to do? Well, the problem is that most clocks just display whatever the system clock says. WorldClock is different, the settings has a UTC option. However, when I used this option with the above TZ variable, it thought I was inside the daylight saving period for London, when it should have been Canberra.

The solution was the third TZ variable, which is the GMT offset together with my LOCAL daylight saving parameters. Now it does not say that you can use a particular timezone with a different timezones daylight saving parameters, but I thought I would give it a go. When I rebooted (you have to to pick up the TZ variable) my clock still came up one hour out. Then TIME868 did its thing and reset the 3600 seconds (see image above).

> `REM GMT WITH LOCAL D/SAVING
> SET TZ=BST0BDT,10,-1,0,7200,3,-1,0,7200,3600
> `

## The Result

I now have my system clock set to UTC (and being maintained by TIME868) so when I fire up an astronomy program all will be well.

I have a clock display (WorldClock) that shows the correct local time.

Note on the WorldClock display the London time is one hour different from UTC, because of daylight saving. Setting this back is automatically handled by WorldClock.

While running with this setup most if not all the other clock programs will not show the correct time

I have not tested this setup under Xfree86 yet, but I'm pretty sure there are programs that will handle the system clock set to UTC.

I also understand that eCS has a clock that will handle UTC but I have not seen it yet.

Note: Most other programs will also pick up the UTC time unless they have an option to change it. In case of e-mail or news clients this may even lead to your message being rejected by the server.

TIME868: The following is an extract from the TIME868 help file. Apart from being the most stable and bullet proof application I have it also contains a nice explanation of the TZ variable.

Use TIME868 to set your system clock using the Time Protocol. This protocol is accurate to plus or minus one second. A variety of features support several modes of operation for both permanent and dial-up access to time servers.

TIME868 also operates as a Time Server for redistribution of accurate time to local clients.

TIME868 provides a graph of the adjustments made for visual reference.

Related Information:

- Choosing a time server
- Setting up the program
- TZ environment variable
- Dialog fields
- Providing a time server
- USNO time server
- National Institute of Standards and Technology

TZ: The TZ (Time Zone) variable, I suppose most people use it but never have a requirement to change it. For those that want to understand more, the best explanation I have found is in the help for Worldclock. For those that do not have Worldclock the complete variable is:

> `SET TZ=STD[+-]nDST[,DSTm,DSTw,DSTd,DSTt,STDm,STDw,STDd,STDt,shift]`

Note there are two efective parts to this variable, the part up to and including nDST, then the rest. Some systems run with just the first part and ignore the daylight saving second part.

> `STD` Standard time (3 characters)
> `n` Difference to UTC(GMT) in hours.+ve west of 0 degrees, -ve east of 0 degrees
> `DST` Daylight saving descriptor
> `DSTm` Month when daylight saving starts
> `DSTw` Week in which daylight saving starts
> `DSTd` Day in which daylight saving starts(0=Sunday)
> `STDm` Month in which daylight saving ends
> `STDw` Week in which daylight saving ends
> `STDd` Day in which daylight saving ends(0=Sunday)
> `STDt` Time of daylight saving in seconds
> `shift` Size of Time shift in seconds.

Note: if you change the TZ variable you have to reboot for the system to pickup the change.

References: Brian Crook's web site - http://www.webone.com.au/~bnc Worldclock - http://www.os2world.com/goran/clock.htm SYSBAR - http://hobbes.nmsu.edu/pub/os2/util/wps/sbr2_017.zip Time868_ZIP - http://hobbes.nmsu.edu/pub/os2/apps/internet/time/time868f.zip

[Feature Index]
editor@os2voice.org
[Previous Page] [Newsletter Index] [Next Page]
VOICE Home Page: http://www.os2voice.org