1: /*	@(#)timezone.c	2.1	SCCS id keyword	*/
   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: }

Defined functions

timezone defined in line 25; used 9 times

Defined variables

zonetab defined in line 15; used 1 times
  • in line 31

Defined struct's

zone defined in line 11; used 2 times
  • in line 27(2)
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 594
Valid CSS Valid XHTML 1.0 Strict