1 /* @(#)timezone.c 4.1 (Berkeley) 12/21/80 */ 2 /* 3 * The arguments are the number of minutes of time 4 * you are westward from Greenwich and whether DST is in effect. 5 * It returns a string 6 * giving the name of the local timezone. 7 * 8 * Sorry, I don't know all the names. 9 */ 10 11 static struct zone { 12 int offset; 13 char *stdzone; 14 char *dlzone; 15 } zonetab[] = { 16 4*60, "AST", "ADT", /* Atlantic */ 17 5*60, "EST", "EDT", /* Eastern */ 18 6*60, "CST", "CDT", /* Central */ 19 7*60, "MST", "MDT", /* Mountain */ 20 8*60, "PST", "PDT", /* Pacific */ 21 0, "GMT", 0, /* Greenwich */ 22 -1 23 }; 24 25 char *timezone(zone, dst) 26 { 27 register struct zone *zp; 28 static char czone[10]; 29 char *sign; 30 31 for (zp=zonetab; zp->offset!=-1; zp++) 32 if (zp->offset==zone) { 33 if (dst && zp->dlzone) 34 return(zp->dlzone); 35 if (!dst && zp->stdzone) 36 return(zp->stdzone); 37 } 38 if (zone<0) { 39 zone = -zone; 40 sign = "+"; 41 } else 42 sign = "-"; 43 sprintf(czone, "GMT%s%d:%02d", sign, zone/60, zone%60); 44 return(czone); 45 } 46