Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!sunic!kth!draken!tut!tukki!otto From: otto@tukki.jyu.fi (Otto J. Makela) Newsgroups: comp.std.internat Subject: Re: International time zones Summary: Small program attempts to guess zone name Message-ID: <1177@tukki.jyu.fi> Date: 21 Aug 89 22:14:59 GMT References: <993@ks.UUCP> <383@shodha.dec.com> <1043@riddle.UUCP> <1044@riddle.UUCP> Reply-To: otto@tukki.jyu.fi (Otto J. Makela) Organization: Grand Hall of Justice, Mega-City One Lines: 97 I wrote this program quite some time ago... Since I've seen CET in place of MET, is this standard ? Who can add to these zone names ? -- /* Display the time zone names with the minute differences given as argument. If "-" is given as argument, switch DST mode */ /* Add: automatic setting of DST depending on current date */ #include #include "config.h" char *timezone(int zone, int dst); main(argc,argv) int argc; char *argv[]; { register int i,j; int arg,dst=0; #ifdef MSDOS *argv="timezone"; #endif if(argc<2) { fprintf(stderr,"usage: %s [-] minutes_east_of_greenwich...\n",*argv); return(1); } for(arg=1; arg0?"east":"west", dst?"during DST ":"",timezone(i,dst)); } } /* The arguments are the number of minutes of time you are eastward from * Greenwich and whether DST is in effect. It returns pointer to a string * giving the name of the local timezone. * * Sorry, I don't know all the names. */ static struct zone { int offset; char *stdzone; char *dlzone; } zonetab[] = { 1*60, "MET", "MET DST", /* Middle European */ 2*60, "EET", "EET DST", /* Eastern European */ -4*60, "AST", "ADT", /* Atlantic */ -5*60, "EST", "EDT", /* Eastern */ -6*60, "CST", "CDT", /* Central */ -7*60, "MST", "MDT", /* Mountain */ -8*60, "PST", "PDT", /* Pacific */ #ifdef notdef /* there's no way to distinguish this from WET */ 0, "GMT", 0, /* Greenwich */ #endif 0*60, "WET", "WET DST", /* Western European */ /* Do they use DST in Australia ? */ 10*60, "EST", "EST", /* Aust: Eastern */ 10*60-30, "CST", "CST", /* Aust: Central */ 8*60, "WST", "WST", /* Aust: Western */ -1 }; char *timezone(zone, dst) { register struct zone *zp; static char czone[10]; char sign = '+'; register char *p, *q; char *getenv(), *index(); for (zp=zonetab; zp->offset!=-1; zp++) if (zp->offset==zone) { if (dst && zp->dlzone) return(zp->dlzone); if (!dst && zp->stdzone) return(zp->stdzone); } /* Not a standard zone, give it as { "+" | "-" } 4digit format */ if (zone<0) { zone = -zone; sign = '-'; } sprintf(czone, "%c%02d%02d", sign, zone/60, zone%60); return(czone); } -- * * * Otto J. Makela (otto@jyu.fi, MAKELA_OTTO_@FINJYU.BITNET) * * * * * * * * Phone: +358 41 613 847, BBS: +358 41 211 562 (CCITT, Bell 2400/1200/300) * * Mail: Kauppakatu 1 B 18, SF-40100 Jyvaskyla, Finland, EUROPE * * * * freopen("/dev/null","r",stdflame); * * * * * * * * * * * * * * * * * *