[comp.sys.sun] Changing Timezones in SunOS 4.0

josm@sun.com (Jos van der Meer) (01/07/89)

See: tzfile(5).

A lot of Template Tzfiles in: /usr/share/lib/zoneinfo.

A way to create these files: zic(8).

Jos van der Meer.

ado@ncifcrf.gov (Arthur David Olson) (01/07/89)

munnari!gaia.oz.au!drm@uunet.uu.net (David Moline) writes:
> Once the timezone has been set for a system under version 4.0 is it
> possible to change it to something else without re-installing the OS.

Using the commands
	zic -l whatever-the-new-time-zone-name-is
	tzsetup
should do the trick.

Arthur David Olson    ado@ncifcrf.gov    ADO is a trademark of Ampex.

dupuy@columbia.edu (Alexander Dupuy) (01/11/89)

One of the really nice things about 4.0 is that Sun has incorporated
Arthur Olson's timezone code, which makes it possible to change the
system's notion of the local timezone without even rebooting!  To change
the local timezone, just rm /usr/lib/zoneinfo and link it to the
appropriate file, e.g.:

amsterdam# date
Tue Jan  3 17:54:40 EST 1989
amsterdam# rm /usr/lib/zoneinfo/localtime
amsterdam# ln /usr/lib/zoneinfo/Navajo /usr/lib/zoneinfo/localtime
amsterdam# date
Tue Jan  3 15:55:53 MST 1989
amsterdam# rm /usr/lib/zoneinfo/localtime
amsterdam# ln /usr/lib/zoneinfo/US/Eastern /usr/lib/zoneinfo/localtime
amsterdam# date
Tue Jan  3 17:56:27 EST 1989

Of course, the various daemons may be running in the old timezone, so you
might want to go to single-user (via shutdown) and then back to multi-user
after doing this.

Actually, now that I've looked at the manual page, I see I could have used
the commands "/usr/etc/zic -l Navajo" and "zic -l US/Eastern" to do the
same thing more easily (and portably).

You can even create new timezones using zic.  You can look at the file
/usr/share/lib/zoninfo/australasia and modify it as needed, then run zic
on it.

This stuff is really neat if you're into obscure time-related trivia, like
me.  The only things which the Sun stuff doesn't handle are solar time
(they compiled the code with NOSOLAR defined, argh) and leap seconds, for
which support was added in a later version of Olson's code (now in
4.3-tahoe).

@alex

bob@kahala.hig.hawaii.edu (Bob Cunningham) (01/11/89)

> ...Or are you (seriously, now) putting Suns on boats?  --wnl

If anyone else out there has Suns aboard ships that do indeed voyage
across time zones (we do), I strongly suggest that you stick to GMT.

ted@braggvax.arpa (01/12/89)

>From:    munnari!gaia.oz.au!drm@uunet.uu.net (David Moline)
>Once the timezone has been set for a system under version 4.0 is it
>possible to change it to something else without re-installing the OS.

Don't know about 4.0, but in 3.X, there is a kernel varible tz which is
just a structure of 2 ints, the first of which is minutes west of GMT (300
for EST) and the second of which is what kind of Daylight savings is in
effect.  Here's the values from /sys/h/time.h

struct timezone {
        int     tz_minuteswest; /* minutes west of Greenwich */
        int     tz_dsttime;     /* type of dst correction */
};
#define DST_NONE        0       /* not on dst */
#define DST_USA         1       /* USA style dst */
#define DST_AUST        2       /* Australian style dst */
#define DST_WET         3       /* Western European dst */
#define DST_MET         4       /* Middle European dst */
#define DST_EET         5       /* Eastern European dst */
#define DST_CAN         6       /* Canada */
#define DST_GB          7       /* Great Britain and Eire */
#define DST_RUM         8       /* Rumania */
#define DST_TUR         9       /* Turkey */
#define DST_AUSTALT     10      /* Australian style with shift in 1986 */

It is quite feasible to change tz with adb, both for keeps in /vmunix and
on the fly in /dev/kmem.  Perhaps 4.0 has something similar, or better
maybe it is all read from a file somewhere.

	Ted Nolan
	ted@braggvax.arpa

guy@uunet.uu.net (Guy Harris) (01/12/89)

>Once the timezone has been set for a system under version 4.0 is it
>possible to change it to something else without re-installing the OS.

"Change it" in what sense?  If you have to change the rules, you can do
that without reinstalling the OS; just edit the appropriate "source" file
("/usr/share/lib/zoneinfo/australasia", in your case) to reflect the new
rules, and run "zic -l <local time zone name>".  See ZIC(8).

Oh yes, and when you've changed the rules, please:

	1) let your local Sun office know, and ask them to send the
	   changes back to Mountain View;

	2) mail the updated version, along with an explanation, to
	   "...!uunet!elsie!ado", the guy who created the "read the rules
	   files" stuff in the first place, so he can let everybody
	   *else* using that stuff know.

If you want to change which zone you're in, just run "zic -l <local time
zone name>", or if you like changing the oil yourself, remove the link
"/usr/share/lib/zoneinfo/localtime" and relink it to the appropriate time
zone file.

Any programs started after the "zic" run will pick up the new rules; any
programs (such as daemons, e.g. "cron") started before then will have to
be restarted (unless they haven't read the file yet, but that's unlikely
to be the case).

(Moderator:)
>What an odd question!  Do timezones move all that often in the "land
>down under"?

Move, I don't know, but *change*, definitely.  That's probably why Robert
Elz, an Australian, was one of the people involved in developing the "read
the rules file" stuff, along with Arthur Olson ("...!elsie!ado"), and a
cast of ones.  Read through "/usr/share/lib/zoneinfo/australasia" for some
interesting commentary.

>If it is a fix that only needs to be done once, are you all
>that upset about remaking the system?

Actually, you don't have to remake anything, now that the rules are
encoded in files.

[[ Bizarre!  --wnl ]]

ESC1298@ESOC.BITNET (Danielle Heinzer) (01/13/89)

Hi, David

I had the same problem as you as I installed SunOS 4.0.  The timezone
definition is not in the kernel configuration file anymore.

The current TimeZone is given by the file:
/usr/share/lib/zoneinfo/localtime.

If you do a 'ls /usr/share/lib/zoneinfo', you will see all the timezones
that the system knows.

For instance, I had installed the Operating System with TimeZone=MET. I
had to change it to GMT.

I did the following as superuser:
     cd /usr/share/lib/zoneinfo
     rm localtime
     ln -s localtime GMT

I don't remember, but I think it acts immediately. You don't need to
reboot.

Regards,

Danielle Heinzer
ESA Computer Department/Computer Services
European Space Operations Centre
Robert-Bosch-str. 5
6100 Darmstadt
West-Germany
Tel int : 49-6151-886540

jim@eda.com (Jim Budler) (01/13/89)

SunOS 4 has a configurable timezone, and definately does not require
reconfiguring or reinstalling the OS to change the TZ.

In /usr/lib/zoneinfo (really /usr/share/lib/zoneinfo) are files with
exotic names like PST8PDT, or Australia/NSW

Also in /usr/lib/zoneinfo is a symbolic link `localtime' which points to
the local time zone file ( in my case PST8PDT ). Change the link to point
to a different time zone.

In the case of the 386i localtime points to /etc/localtime, which point
back to /usr/share/lib/zoneinfo/XXX, because of the read only /usr. Of
course, if you want to create a NEW timezone on a 386i you'll have some
difficulty creating the file in /usr/lib/zoneinfo 8^) Change
/etc/localtime to point to the new timezone.

After changing the timezone this way you should (as root) execute
/usr/etc/tzsetup. This converts the in kernel value, used only by 3.X
binaries to match the new value.

jim
-- 
Jim Budler   address = uucp: ...!{decwrl,uunet}!eda!jim OR domain: jim@eda.com

jim@eda.com (Jim Budler) (01/13/89)

elsie!ado@ncifcrf.gov (Arthur David Olson) writes:
> Using the commands
> 	zic -l whatever-the-new-time-zone-name-is
> 	tzsetup
> should do the trick.

Unfortunately not on a Sun386i. Because of the read only /usr filesystem.
(Why did they do this??? I'm more and more tempted to turn this off, every
time I run into something like this.)

On non-386i:

	# cd /usr/share/lib/zoneinfo
	# rm localtime
	# ln -s whatever-the-new-time-zone-name-is localtime
	# tzsetup

On 386i:

	# cd /etc
	# rm localtime
	# ln -s /usr/share/lib/zoneinfo/whatever... localtime
	# tzsetup

Sun left a link at /usr/share/lib/zoneinfo/localtime pointing to
/etc/localtime to fool most of the programs. It doesn't fool zic.

jim

Jim Budler   address = uucp: ...!{decwrl,uunet}!eda!jim
					 domain: jim@eda.com

thorstad@wooglin.scc.com (Brian Thorstad) (01/19/89)

D. Moline writes:
> Once the timezone has been set for a system under version 4.0 is it
> possible to change it to something else without re-installing the OS.

and our moderator adds:
> [[ Do timezones move all that often in the "land
> down under"?  --wnl ]]

While I agree that not too many machines move across time zones, very few
machines arrive with the correct time zone set by default (say those
delivered to the west coast of the U.S.?).  I was very disappointed when I
added a lone sun/3 to my 386i network and found that I had to reconfigure
the kernel to get the date correct.

Brian Thorstad
(thorstad@wooglin.scc.com)