Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!iuvax!pur-ee!mentor.cc.purdue.edu!nelson From: nelson@mentor.cc.purdue.edu (J. Nelson Howell) Newsgroups: comp.sys.ibm.pc.rt Subject: Re: How to set time zone in AOS (BSD 4.3)? Message-ID: <7677@mentor.cc.purdue.edu> Date: 20 Feb 90 21:26:18 GMT References: <24325@princeton.Princeton.EDU> Reply-To: nelson@mentor.cc.purdue.edu (J. Nelson Howell) Organization: Purdue University Lines: 128 In article <24325@princeton.Princeton.EDU> you write: >The subject line says it. All help appreciated. Please post rather >than sending email. > Can you say "kernal rebuild"? I went through this already. You must go into the system configuration files, reset the time zone variable, then rebuild the kernal. If you don't mind resetting the zone each time you boot, I am including a piece of code that will reset it for you. Hope this helps. J. Nelson Howell System Programmer nelson@midas.mgmt.purdue.edu Krannert Graduate School of Management NELSON@PURCCVM.BITNET Purdue University, West Lafayette, IN 47907 ------ cut here ------ /* * settz.c - reset the time zone to local conditions * * Author: J. Nelson Howell 88/11/09 */ #include #include /* globals */ struct timeval t; struct timezone tz; int zoneoffset[5] = {300,300,360,420,480}; /* US continental time zones */ int dsttype[5] = {0,1,1,1,1}; /* DST correction flag */ char *czones[5] = {"est","edt","cdt","mdt","pdt"}; enum {EST,EDT,CDT,MDT,PDT}; /* US continental time zones */ main(argc,argv) int argc; char **argv; { int localzone; if(--argc == 0) { /* give some help */ usage(); exit(0); } argv++; if(!strcmp(*argv,"show")) { /* inform the user of the current time and zone info */ showzone(); exit(0); } if(!strcmp(*argv,"set")) { argv++; argc--; if(!argc) { usage(); exit(-1); } for(localzone=EST;localzone<=PDT;localzone++) { if(strcmp(*argv,czones[localzone])) { if(localzone == PDT) { badzone(*argv); } else { continue; } } else { /* got a correct timezone */ break; } } /* get the current system time */ gettimeofday(&t,&tz); tz.tz_minuteswest = zoneoffset[localzone]; tz.tz_dsttime = dsttype[localzone]; if(settimeofday(&t,&tz)) { printf("time zone can only be set by super-user\n"); exit(-1); } else { showzone(); exit(0); } } else { usage(); exit(-1); } } showzone() /* display the current time and zone structures */ { gettimeofday(&t,&tz); printf("seconds since 1/1/1970: %ld\n",t.tv_sec); printf("usecs : %ld\n",t.tv_usec); printf("minutes west of GMT : %d\n",tz.tz_minuteswest); printf("DST correction code : %d\n",tz.tz_dsttime); } usage() /* display usage syntax */ { printf("settz {show|set }\n"); printf("\tvalid zones are: EST\n"); printf("\t EDT\n"); printf("\t CDT\n"); printf("\t MDT\n"); printf("\t PDT\n"); printf("EST does not change to daylight savings time\n\n"); } badzone(zone) char *zone; /* inform the user that a bad zone has been supplied */ { printf("%s is not a valid zone\n\n",zone); usage(); exit(-1); } ------ cut here ------