home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / dosutils / gtar109 / getdate.y < prev    next >
Text File  |  1991-01-14  |  14KB  |  632 lines

  1. %token ID MONTH DAY MERIDIAN NUMBER UNIT MUNIT SUNIT ZONE DAYZONE AGO DST
  2. %{
  3.     /*     Originally from: Steven M. Bellovin (unc!smb)    */
  4.     /*    Dept. of Computer Science            */
  5.     /*    University of North Carolina at Chapel Hill    */
  6.     /*    @(#)getdate.y    2.17    11/30/87            */
  7.  
  8. /* #include "defs.h" JF not used any more */
  9. #include <sys/types.h>
  10. #ifdef USG
  11. struct timeb
  12. {
  13.     time_t    time;
  14.     unsigned short millitm;
  15.     short    timezone;
  16.     short    dstflag;
  17. };
  18. static void ftime ();
  19. #else
  20. #include <sys/timeb.h>
  21. #endif
  22. #include <ctype.h>
  23.  
  24. #if defined(BSD4_2) || defined (BSD4_1C)
  25. #include <sys/time.h>
  26. #else /* sane */
  27. #include <time.h>
  28. #endif /* sane */
  29.  
  30. #if defined (STDC_HEADERS) || defined (USG)
  31. #include <string.h>
  32. #endif
  33.  
  34. #ifdef __GNUC__
  35. #define alloca __builtin_alloca
  36. #else
  37. #ifdef sparc
  38. #include <alloca.h>
  39. #endif
  40. #endif
  41.  
  42. #ifndef NULL
  43. #define    NULL    0
  44. #endif
  45. #define daysec (24L*60L*60L)
  46.     static int timeflag, zoneflag, dateflag, dayflag, relflag;
  47.     static time_t relsec, relmonth;
  48.     static int hh, mm, ss, merid, day_light;
  49.     static int dayord, dayreq;
  50.     static int month, day, year;
  51.     static int ourzone;
  52. #define AM 1
  53. #define PM 2
  54. #define DAYLIGHT 1
  55. #define STANDARD 2
  56. #define MAYBE    3
  57.  
  58. static time_t timeconv();
  59. static time_t daylcorr();
  60. static lookup();
  61. static yylex();
  62. static yyerror();
  63.  
  64. static int yylex ();
  65. #define yyparse getdate_yyparse
  66. static int yyerror ();
  67.  
  68. %}
  69.  
  70. %%
  71. timedate:         /* empty */
  72.     | timedate item
  73.     ;
  74.  
  75. item:    tspec
  76.         {timeflag++;}
  77.     | zone
  78.         {zoneflag++;}
  79.     | dtspec
  80.         {dateflag++;}
  81.     | dyspec
  82.         {dayflag++;}
  83.     | rspec
  84.         {relflag++;}
  85.     | nspec;
  86.  
  87. nspec:    NUMBER
  88.         {if (timeflag && dateflag && !relflag) year = $1;
  89.         else if ($1 > 10000) {
  90.             dateflag++;
  91.             day= $1%100;
  92.             month= ($1/100)%100;
  93.             year = month/10000;
  94.         } else {timeflag++;hh = $1/100;mm = $1%100;ss = 0;merid = 24;}};
  95.  
  96. tspec:    NUMBER MERIDIAN
  97.         {hh = $1; mm = 0; ss = 0; merid = $2;}
  98.     | NUMBER ':' NUMBER
  99.         {hh = $1; mm = $3; merid = 24;}
  100.     | NUMBER ':' NUMBER MERIDIAN
  101.         {hh = $1; mm = $3; merid = $4;}
  102.     | NUMBER ':' NUMBER NUMBER
  103.         {hh = $1; mm = $3; merid = 24;
  104.         day_light = STANDARD; ourzone = -($4%100 + 60*($4/100));}
  105.     | NUMBER ':' NUMBER ':' NUMBER
  106.         {hh = $1; mm = $3; ss = $5; merid = 24;}
  107.     | NUMBER ':' NUMBER ':' NUMBER MERIDIAN
  108.         {hh = $1; mm = $3; ss = $5; merid = $6;}
  109.     | NUMBER ':' NUMBER ':' NUMBER NUMBER
  110.         {hh = $1; mm = $3; ss = $5; merid = 24;
  111.         day_light = STANDARD; ourzone = -($6%100 + 60*($6/100));};
  112.  
  113. zone:    ZONE dst
  114.         {ourzone = $1; day_light = $2;}
  115.     | DAYZONE
  116.         {ourzone = $1; day_light = DAYLIGHT;};
  117.  
  118. dst:    /* empty */
  119.         { $$ = STANDARD; }
  120.     | DST
  121.         { $$ = DAYLIGHT; };
  122.  
  123. dyspec:    DAY
  124.         {dayord = 1; dayreq = $1;}
  125.     | DAY ','
  126.         {dayord = 1; dayreq = $1;}
  127.     | NUMBER DAY
  128.         {dayord = $1; dayreq = $2;};
  129.  
  130. dtspec:    NUMBER '/' NUMBER
  131.         {month = $1; day = $3;}
  132.     | NUMBER '/' NUMBER '/' NUMBER
  133.         {month = $1; day = $3; year = $5;}
  134.     | MONTH NUMBER
  135.         {month = $1; day = $2;}
  136.     | MONTH NUMBER ',' NUMBER
  137.         {month = $1; day = $2; year = $4;}
  138.     | NUMBER MONTH
  139.         {month = $2; day = $1;}
  140.     | NUMBER MONTH NUMBER
  141.         {month = $2; day = $1; year = $3;};
  142.  
  143.  
  144. rspec:    NUMBER UNIT
  145.         {relsec +=  60L * $1 * $2;}
  146.     | NUMBER MUNIT
  147.         {relmonth += $1 * $2;}
  148.     | NUMBER SUNIT
  149.         {relsec += $1;}
  150.     | UNIT
  151.         {relsec +=  60L * $1;}
  152.     | MUNIT
  153.         {relmonth += $1;}
  154.     | SUNIT
  155.         {relsec++;}
  156.     | rspec AGO
  157.         {relsec = -relsec; relmonth = -relmonth;};
  158. %%
  159.  
  160. static int mdays[12] =
  161.     {31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31};
  162. #define epoch 1970
  163.  
  164. extern struct tm *localtime();
  165.  
  166. static time_t
  167. dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
  168. int mm, dd, yy, h, m, s, mer, zone, dayflag;
  169. {
  170.     time_t tod, jdate;
  171.     register int i;
  172.  
  173.     if (yy < 0) yy = -yy;
  174.     if (yy < 100) yy += 1900;
  175.     mdays[1] = 28 + (yy%4 == 0 && (yy%100 != 0 || yy%400 == 0));
  176.     if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||
  177.         dd < 1 || dd > mdays[--mm]) return (-1);
  178.     jdate = dd-1;
  179.         for (i=0; i<mm; i++) jdate += mdays[i];
  180.     for (i = epoch; i < yy; i++) jdate += 365 + (i%4 == 0);
  181.     jdate *= daysec;
  182.     jdate += zone * 60L;
  183.     if ((tod = timeconv(h, m, s, mer)) < 0) return (-1);
  184.     jdate += tod;
  185.     if (dayflag==DAYLIGHT || (dayflag==MAYBE&&localtime(&jdate)->tm_isdst))
  186.         jdate += -1*60*60;
  187.     return (jdate);
  188. }
  189.  
  190. static time_t
  191. dayconv(ord, day, now)
  192. int ord, day; time_t now;
  193. {
  194.     register struct tm *loctime;
  195.     time_t tod;
  196.  
  197.     tod = now;
  198.     loctime = localtime(&tod);
  199.     tod += daysec * ((day - loctime->tm_wday + 7) % 7);
  200.     tod += 7*daysec*(ord<=0?ord:ord-1);
  201.     return daylcorr(tod, now);
  202. }
  203.  
  204. static time_t
  205. timeconv(hh, mm, ss, mer)
  206. register int hh, mm, ss, mer;
  207. {
  208.     if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1);
  209.     switch (mer) {
  210.         case AM: if (hh < 1 || hh > 12) return(-1);
  211.              return (60L * ((hh%12)*60L + mm)+ss);
  212.         case PM: if (hh < 1 || hh > 12) return(-1);
  213.              return (60L * ((hh%12 +12)*60L + mm)+ss);
  214.         case 24: if (hh < 0 || hh > 23) return (-1);
  215.              return (60L * (hh*60L + mm)+ss);
  216.         default: return (-1);
  217.     }
  218. }
  219.  
  220. static time_t
  221. monthadd(sdate, relmonth)
  222. time_t sdate, relmonth;
  223. {
  224.     struct tm *ltime;
  225.     time_t dateconv();
  226.     int mm, yy;
  227.  
  228.     if (relmonth == 0) return 0;
  229.     ltime = localtime(&sdate);
  230.     mm = 12*ltime->tm_year + ltime->tm_mon + relmonth;
  231.     yy = mm/12;
  232.     mm = mm%12 + 1;
  233.     return daylcorr(dateconv(mm, ltime->tm_mday, yy, ltime->tm_hour,
  234.         ltime->tm_min, ltime->tm_sec, 24, ourzone, MAYBE), sdate);
  235. }
  236.  
  237. static time_t
  238. daylcorr(future, now)
  239. time_t future, now;
  240. {
  241.     int fdayl, nowdayl;
  242.  
  243.     nowdayl = (localtime(&now)->tm_hour+1) % 24;
  244.     fdayl = (localtime(&future)->tm_hour+1) % 24;
  245.     return (future-now) + 60L*60L*(nowdayl-fdayl);
  246. }
  247.  
  248. static char *lptr;
  249.  
  250. static int
  251. yylex()
  252. {
  253.     extern int yylval;
  254.     int sign;
  255.     register char c;
  256.     register char *p;
  257.     char idbuf[20];
  258.     int pcnt;
  259.  
  260.     for (;;) {
  261.         while (isspace(*lptr))
  262.             lptr++;
  263.  
  264.         if (isdigit(c = *lptr) || c == '-' || c == '+') {
  265.             if (c== '-' || c == '+') {
  266.                 if (c=='-') sign = -1;
  267.                 else sign = 1;
  268.                 if (!isdigit(*++lptr)) {
  269.                     /* yylval = sign; return (NUMBER); */
  270.                     return yylex();    /* skip the '-' sign */
  271.                 }
  272.             } else sign = 1;
  273.             yylval = 0;
  274.             while (isdigit(c = *lptr++))
  275.                 yylval = 10*yylval + c - '0';
  276.             yylval *= sign;
  277.             lptr--;
  278.             return (NUMBER);
  279.  
  280.         } else if (isalpha(c)) {
  281.             p = idbuf;
  282.             while (isalpha(c = *lptr++) || c=='.')
  283.                 if (p < &idbuf[sizeof(idbuf)-1]) *p++ = c;
  284.             *p = '\0';
  285.             lptr--;
  286.             return (lookup(idbuf));
  287.         }
  288.  
  289.         else if (c == '(') {
  290.             pcnt = 0;
  291.             do {
  292.                 c = *lptr++;
  293.                 if (c == '\0') return(c);
  294.                 else if (c == '(') pcnt++;
  295.                 else if (c == ')') pcnt--;
  296.             } while (pcnt > 0);
  297.         }
  298.  
  299.         else return (*lptr++);
  300.     }
  301. }
  302.  
  303. struct table {
  304.     char *name;
  305.     int type, value;
  306. };
  307.  
  308. static struct table mdtab[] = {
  309.     {"january", MONTH, 1},
  310.     {"february", MONTH, 2},
  311.     {"march", MONTH, 3},
  312.     {"april", MONTH, 4},
  313.     {"may", MONTH, 5},
  314.     {"june", MONTH, 6},
  315.     {"july", MONTH, 7},
  316.     {"august", MONTH, 8},
  317.     {"september", MONTH, 9},
  318.     {"sept", MONTH, 9},
  319.     {"october", MONTH, 10},
  320.     {"november", MONTH, 11},
  321.     {"december", MONTH, 12},
  322.  
  323.     {"sunday", DAY, 0},
  324.     {"monday", DAY, 1},
  325.     {"tuesday", DAY, 2},
  326.     {"tues", DAY, 2},
  327.     {"wednesday", DAY, 3},
  328.     {"wednes", DAY, 3},
  329.     {"thursday", DAY, 4},
  330.     {"thur", DAY, 4},
  331.     {"thurs", DAY, 4},
  332.     {"friday", DAY, 5},
  333.     {"saturday", DAY, 6},
  334.     {0, 0, 0}
  335. };
  336.  
  337. #define HRS *60
  338. #define HALFHR 30
  339.  
  340. static struct table mztab[] = {
  341.     {"a.m.", MERIDIAN, AM},
  342.     {"am", MERIDIAN, AM},
  343.     {"p.m.", MERIDIAN, PM},
  344.     {"pm", MERIDIAN, PM},
  345.     {"nst", ZONE, 3 HRS + HALFHR},        /* Newfoundland */
  346.     {"n.s.t.", ZONE, 3 HRS + HALFHR},
  347.     {"ast", ZONE, 4 HRS},        /* Atlantic */
  348.     {"a.s.t.", ZONE, 4 HRS},
  349.     {"adt", DAYZONE, 4 HRS},
  350.     {"a.d.t.", DAYZONE, 4 HRS},
  351.     {"est", ZONE, 5 HRS},        /* Eastern */
  352.     {"e.s.t.", ZONE, 5 HRS},
  353.     {"edt", DAYZONE, 5 HRS},
  354.     {"e.d.t.", DAYZONE, 5 HRS},
  355.     {"cst", ZONE, 6 HRS},        /* Central */
  356.     {"c.s.t.", ZONE, 6 HRS},
  357.     {"cdt", DAYZONE, 6 HRS},
  358.     {"c.d.t.", DAYZONE, 6 HRS},
  359.     {"mst", ZONE, 7 HRS},        /* Mountain */
  360.     {"m.s.t.", ZONE, 7 HRS},
  361.     {"mdt", DAYZONE, 7 HRS},
  362.     {"m.d.t.", DAYZONE, 7 HRS},
  363.     {"pst", ZONE, 8 HRS},        /* Pacific */
  364.     {"p.s.t.", ZONE, 8 HRS},
  365.     {"pdt", DAYZONE, 8 HRS},
  366.     {"p.d.t.", DAYZONE, 8 HRS},
  367.     {"yst", ZONE, 9 HRS},        /* Yukon */
  368.     {"y.s.t.", ZONE, 9 HRS},
  369.     {"ydt", DAYZONE, 9 HRS},
  370.     {"y.d.t.", DAYZONE, 9 HRS},
  371.     {"hst", ZONE, 10 HRS},        /* Hawaii */
  372.     {"h.s.t.", ZONE, 10 HRS},
  373.     {"hdt", DAYZONE, 10 HRS},
  374.     {"h.d.t.", DAYZONE, 10 HRS},
  375.  
  376.     {"gmt", ZONE, 0 HRS},
  377.     {"g.m.t.", ZONE, 0 HRS},
  378.     {"bst", DAYZONE, 0 HRS},        /* British Summer Time */
  379.     {"b.s.t.", DAYZONE, 0 HRS},
  380.     {"eet", ZONE, 0 HRS},        /* European Eastern Time */
  381.     {"e.e.t.", ZONE, 0 HRS},
  382.     {"eest", DAYZONE, 0 HRS},    /* European Eastern Summer Time */
  383.     {"e.e.s.t.", DAYZONE, 0 HRS},
  384.     {"met", ZONE, -1 HRS},        /* Middle European Time */
  385.     {"m.e.t.", ZONE, -1 HRS},
  386.     {"mest", DAYZONE, -1 HRS},    /* Middle European Summer Time */
  387.     {"m.e.s.t.", DAYZONE, -1 HRS},
  388.     {"wet", ZONE, -2 HRS },        /* Western European Time */
  389.     {"w.e.t.", ZONE, -2 HRS },
  390.     {"west", DAYZONE, -2 HRS},    /* Western European Summer Time */
  391.     {"w.e.s.t.", DAYZONE, -2 HRS},
  392.  
  393.     {"jst", ZONE, -9 HRS},        /* Japan Standard Time */
  394.     {"j.s.t.", ZONE, -9 HRS},    /* Japan Standard Time */
  395.                     /* No daylight savings time */
  396.  
  397.     {"aest", ZONE, -10 HRS},    /* Australian Eastern Time */
  398.     {"a.e.s.t.", ZONE, -10 HRS},
  399.     {"aesst", DAYZONE, -10 HRS},    /* Australian Eastern Summer Time */
  400.     {"a.e.s.s.t.", DAYZONE, -10 HRS},
  401.     {"acst", ZONE, -(9 HRS + HALFHR)},    /* Australian Central Time */
  402.     {"a.c.s.t.", ZONE, -(9 HRS + HALFHR)},
  403.     {"acsst", DAYZONE, -(9 HRS + HALFHR)},    /* Australian Central Summer */
  404.     {"a.c.s.s.t.", DAYZONE, -(9 HRS + HALFHR)},
  405.     {"awst", ZONE, -8 HRS},        /* Australian Western Time */
  406.     {"a.w.s.t.", ZONE, -8 HRS},    /* (no daylight time there, I'm told */
  407.     {"dst", DST, 0},        /* Explicit daylight time */
  408.     {0, 0, 0}};
  409.  
  410. static struct table unittb[] = {
  411.     {"year", MUNIT, 12},
  412.     {"month", MUNIT, 1},
  413.     {"fortnight", UNIT, 14*24*60},
  414.     {"week", UNIT, 7*24*60},
  415.     {"day", UNIT, 1*24*60},
  416.     {"hour", UNIT, 60},
  417.     {"minute", UNIT, 1},
  418.     {"min", UNIT, 1},
  419.     {"second", SUNIT, 1},
  420.     {"sec", SUNIT, 1},
  421.     {0, 0, 0}};
  422.  
  423. static struct table othertb[] = {
  424.     {"tomorrow", UNIT, 1*24*60},
  425.     {"yesterday", UNIT, -1*24*60},
  426.     {"today", UNIT, 0},
  427.     {"now", UNIT, 0},
  428.     {"last", NUMBER, -1},
  429.     {"this", UNIT, 0},
  430.     {"next", NUMBER, 2},
  431.     {"first", NUMBER, 1},
  432.     /* {"second", NUMBER, 2}, */
  433.     {"third", NUMBER, 3},
  434.     {"fourth", NUMBER, 4},
  435.     {"fifth", NUMBER, 5},
  436.     {"sixth", NUMBER, 6},
  437.     {"seventh", NUMBER, 7},
  438.     {"eigth", NUMBER, 8},
  439.     {"ninth", NUMBER, 9},
  440.     {"tenth", NUMBER, 10},
  441.     {"eleventh", NUMBER, 11},
  442.     {"twelfth", NUMBER, 12},
  443.     {"ago", AGO, 1},
  444.     {0, 0, 0}};
  445.  
  446. static struct table milzone[] = {
  447.     {"a", ZONE, 1 HRS},
  448.     {"b", ZONE, 2 HRS},
  449.     {"c", ZONE, 3 HRS},
  450.     {"d", ZONE, 4 HRS},
  451.     {"e", ZONE, 5 HRS},
  452.     {"f", ZONE, 6 HRS},
  453.     {"g", ZONE, 7 HRS},
  454.     {"h", ZONE, 8 HRS},
  455.     {"i", ZONE, 9 HRS},
  456.     {"k", ZONE, 10 HRS},
  457.     {"l", ZONE, 11 HRS},
  458.     {"m", ZONE, 12 HRS},
  459.     {"n", ZONE, -1 HRS},
  460.     {"o", ZONE, -2 HRS},
  461.     {"p", ZONE, -3 HRS},
  462.     {"q", ZONE, -4 HRS},
  463.     {"r", ZONE, -5 HRS},
  464.     {"s", ZONE, -6 HRS},
  465.     {"t", ZONE, -7 HRS},
  466.     {"u", ZONE, -8 HRS},
  467.     {"v", ZONE, -9 HRS},
  468.     {"w", ZONE, -10 HRS},
  469.     {"x", ZONE, -11 HRS},
  470.     {"y", ZONE, -12 HRS},
  471.     {"z", ZONE, 0 HRS},
  472.     {0, 0, 0}};
  473.  
  474. static int
  475. lookup(id)
  476. char *id;
  477. {
  478. #define gotit (yylval=i->value,  i->type)
  479.  
  480.     char idvar[128];
  481.     register char *j, *k;
  482.     register struct table *i;
  483.     int abbrev;
  484.  
  485.     (void) strcpy(idvar, id);
  486.     j = idvar;
  487.     k = id - 1;
  488.     while (*++k)
  489.         *j++ = isupper(*k) ? tolower(*k) : *k;
  490.     *j = '\0';
  491.  
  492.     if (strlen(idvar) == 3)
  493.         abbrev = 1;
  494.     else
  495.         if (strlen(idvar) == 4 && idvar[3] == '.' && idvar[1] != '.') {
  496.             abbrev = 1;
  497.             idvar[3] = '\0';
  498.         }
  499.     else
  500.         abbrev = 0;
  501.  
  502.     for (i = mdtab; i->name; i++) {
  503.         k = idvar;
  504.         for (j = i->name; *j++ == *k++;) {
  505.             if (abbrev && j == i->name+3)
  506.                 return gotit;
  507.             if (j[-1] == 0)
  508.                 return gotit;
  509.         }
  510.     }
  511.  
  512.     for (i=mztab; i->name; i++)
  513.         if (strcmp(i->name, idvar) == 0)
  514.             return gotit;
  515.  
  516.     for (i=unittb; i->name; i++)
  517.         if (strcmp(i->name, idvar) == 0)
  518.             return gotit;
  519.  
  520.     if (idvar[strlen(idvar)-1] == 's')
  521.         idvar[strlen(idvar)-1] = '\0';
  522.  
  523.     for (i=unittb; i->name; i++)
  524.         if (strcmp(i->name, idvar) == 0)
  525.             return gotit;
  526.  
  527.     for (i = othertb; i->name; i++)
  528.         if (strcmp(i->name, idvar) == 0)
  529.             return gotit;
  530.  
  531.     if (strlen(idvar) == 1 && isalpha(*idvar)) {
  532.         for (i = milzone; i->name; i++)
  533.             if (strcmp(i->name, idvar) == 0)
  534.                 return gotit;
  535.     }
  536.  
  537.     return ID;
  538. }
  539.  
  540. time_t
  541. getdate(p, now)
  542. char *p;
  543. struct timeb *now;
  544. {
  545. #define mcheck(f)    if (f>1) err++
  546.     time_t monthadd();
  547.     int err;
  548.     struct tm *lt;
  549.     struct timeb ftz;
  550.  
  551.     time_t sdate, tod;
  552.  
  553.     lptr = p;
  554.     if (now == ((struct timeb *) NULL)) {
  555.         now = &ftz;
  556.         ftime(&ftz);
  557.     }
  558.     lt = localtime(&now->time);
  559.     year = lt->tm_year;
  560.     month = lt->tm_mon+1;
  561.     day = lt->tm_mday;
  562.     relsec = 0; relmonth = 0;
  563.     timeflag=zoneflag=dateflag=dayflag=relflag=0;
  564.     ourzone = now->timezone;
  565.     day_light = MAYBE;
  566.     hh = mm = ss = 0;
  567.     merid = 24;
  568.  
  569.     if (err = yyparse()) return (-1);
  570.  
  571.     mcheck(timeflag);
  572.     mcheck(zoneflag);
  573.     mcheck(dateflag);
  574.     mcheck(dayflag);
  575.  
  576.     if (err) return (-1);
  577.     if (dateflag || timeflag || dayflag) {
  578.         sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,day_light);
  579.         if (sdate < 0) return -1;
  580.     }
  581.     else {
  582.         sdate = now->time;
  583.         if (relflag == 0)
  584.             sdate -= (lt->tm_sec + lt->tm_min*60 +
  585.                 lt->tm_hour*(60L*60L));
  586.     }
  587.  
  588.     sdate += relsec;
  589.     sdate += monthadd(sdate, relmonth);
  590.  
  591.     if (dayflag && !dateflag) {
  592.         tod = dayconv(dayord, dayreq, sdate);
  593.         sdate += tod;
  594.     }
  595.  
  596.     /*
  597.     ** Have to do *something* with a legitimate -1 so it's distinguishable
  598.     ** from the error return value.  (Alternately could set errno on error.)
  599.     */
  600.     return (sdate == -1) ? 0 : sdate;
  601. }
  602.  
  603. static int
  604. yyerror(s)
  605. char *s;
  606. {
  607.   return 0;
  608. }
  609.  
  610. #ifdef USG
  611. static void
  612. ftime(timeb)
  613. struct timeb *timeb;
  614. {
  615.     extern long timezone;
  616. #ifndef DAYLIGHT_MISSING    /* Not all non-BSD libraries have `daylight'. */
  617.     extern int daylight;
  618. #endif
  619.     long t = 0;
  620.  
  621.     localtime(&t);    /* Dummy to init timzeone */
  622.     time(&(timeb->time));
  623.     timeb->millitm=0;
  624.     timeb->timezone=timezone/60;    /* Timezone is in seconds! */
  625. #ifndef DAYLIGHT_MISSING
  626.     timeb->dstflag=daylight;
  627. #else
  628.     timeb->dstflag=0;
  629. #endif
  630. }
  631. #endif
  632.