Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / zotnet / tws / RCS / dtimep.lex,v
1 head    2.15;
2 access;
3 symbols;
4 locks; strict;
5
6
7 2.15
8 date    93.02.26.22.07.40;      author jromine; state Exp;
9 branches;
10 next    2.14;
11
12 2.14
13 date    92.12.15.00.20.22;      author jromine; state Exp;
14 branches;
15 next    2.13;
16
17 2.13
18 date    92.05.19.21.26.05;      author jromine; state Exp;
19 branches;
20 next    2.12;
21
22 2.12
23 date    92.05.19.21.25.17;      author jromine; state Exp;
24 branches;
25 next    2.11;
26
27 2.11
28 date    92.02.10.20.32.29;      author jromine; state Exp;
29 branches;
30 next    2.10;
31
32 2.10
33 date    92.02.09.22.41.24;      author jromine; state Exp;
34 branches;
35 next    2.9;
36
37 2.9
38 date    92.02.07.01.04.07;      author jromine; state Exp;
39 branches;
40 next    2.8;
41
42 2.8
43 date    92.02.07.00.46.23;      author jromine; state Exp;
44 branches;
45 next    2.7;
46
47 2.7
48 date    92.02.07.00.45.31;      author jromine; state Exp;
49 branches;
50 next    2.6;
51
52 2.6
53 date    92.02.07.00.25.45;      author jromine; state Exp;
54 branches;
55 next    2.5;
56
57 2.5
58 date    92.02.07.00.10.21;      author jromine; state Exp;
59 branches;
60 next    2.4;
61
62 2.4
63 date    92.02.07.00.07.37;      author jromine; state Exp;
64 branches;
65 next    2.3;
66
67 2.3
68 date    92.02.07.00.03.39;      author jromine; state Exp;
69 branches;
70 next    2.2;
71
72 2.2
73 date    92.02.07.00.02.09;      author jromine; state Exp;
74 branches;
75 next    2.1;
76
77 2.1
78 date    92.02.06.23.56.12;      author jromine; state Exp;
79 branches;
80 next    2.0;
81
82 2.0
83 date    92.02.06.23.36.10;      author jromine; state Exp;
84 branches;
85 next    1.10;
86
87 1.10
88 date    90.04.05.15.55.07;      author sources; state Exp;
89 branches;
90 next    1.9;
91
92 1.9
93 date    90.03.21.15.34.15;      author sources; state Exp;
94 branches;
95 next    1.8;
96
97 1.8
98 date    90.02.23.13.42.22;      author sources; state Exp;
99 branches;
100 next    1.7;
101
102 1.7
103 date    90.02.08.14.12.10;      author sources; state Exp;
104 branches;
105 next    1.6;
106
107 1.6
108 date    90.02.06.16.31.28;      author sources; state Exp;
109 branches;
110 next    1.5;
111
112 1.5
113 date    90.02.06.16.29.08;      author sources; state Exp;
114 branches;
115 next    1.4;
116
117 1.4
118 date    90.02.06.15.57.59;      author sources; state Exp;
119 branches;
120 next    1.3;
121
122 1.3
123 date    90.02.06.13.42.29;      author sources; state Exp;
124 branches;
125 next    1.2;
126
127 1.2
128 date    90.02.01.14.43.27;      author sources; state Exp;
129 branches;
130 next    1.1;
131
132 1.1
133 date    90.02.01.14.41.24;      author sources; state Exp;
134 branches;
135 next    ;
136
137
138 desc
139 @@
140
141
142 2.15
143 log
144 @386BSD/BSD44
145 @
146 text
147 @%e 2000
148 %p 5000
149 %n 1000
150 %a 4000
151 %START  Z
152 sun     (sun(day)?)
153 mon     (mon(day)?)
154 tue     (tue(sday)?)
155 wed     (wed(nesday)?)
156 thu     (thu(rsday)?)
157 fri     (fri(day)?)
158 sat     (sat(urday)?)
159
160 DAY     ({sun}|{mon}|{tue}|{wed}|{thu}|{fri}|{sat})
161
162 jan     (jan(uary)?)
163 feb     (feb(ruary)?)
164 mar     (mar(ch)?)
165 apr     (apr(il)?)
166 may     (may)
167 jun     (jun(e)?)
168 jul     (jul(y)?)
169 aug     (aug(ust)?)
170 sep     (sep(tember)?)
171 oct     (oct(ober)?)
172 nov     (nov(ember)?)
173 dec     (dec(ember)?)
174
175 MONTH   ({jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec})
176
177 w       ([ \t]*)
178 W       ([ \t]+)
179 D       ([0-9]?[0-9])
180 d       [0-9]
181 %{
182 #ifndef lint
183 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.14 1992/12/15 00:20:22 jromine Exp jromine $";
184 #endif
185 #include "tws.h"
186 #include "../h/strings.h"
187 #include <ctype.h>
188 #include <sys/types.h>
189 #if !defined(SYS5) && !defined(ZONEINFO)
190 #include <sys/timeb.h>
191 #endif /* !defined(SYS5) && !defined(ZONEINFO) */
192
193 #ifdef SYS5
194 extern int  daylight;
195 extern long timezone;
196 extern char *tzname[];
197 #endif /* SYS5 */
198
199 /*
200  * Patchable flag that says how to interpret NN/NN/NN dates. When
201  * true, we do it European style: DD/MM/YY. When false, we do it
202  * American style: MM/DD/YY.  Of course, these are all non-RFC822
203  * compliant.
204  */
205 int europeandate = 0;
206
207 /*
208  * Table to convert month names to numeric month.  We use the
209  * fact that the low order 5 bits of the sum of the 2nd & 3rd
210  * characters of the name is a hash with no collisions for the 12
211  * valid month names.  (The mask to 5 bits maps any combination of
212  * upper and lower case into the same hash value).
213  */
214 static  int month_map[] = {
215         0,
216         6,      /* 1 - Jul */
217         3,      /* 2 - Apr */
218         5,      /* 3 - Jun */
219         0,
220         10,     /* 5 - Nov */
221         0,
222         1,      /* 7 - Feb */
223         11,     /* 8 - Dec */
224         0,
225         0,
226         0,
227         0,
228         0,
229         0,
230         0,      /*15 - Jan */
231         0,
232         0,
233         0,
234         2,      /*19 - Mar */
235         0,
236         8,      /*21 - Sep */
237         0,
238         9,      /*23 - Oct */
239         0,
240         0,
241         4,      /*26 - May */
242         0,
243         7       /*28 - Aug */
244 };
245 /*
246  * Same trick for day-of-week using the hash function
247  *  (c1 & 7) + (c2 & 4)
248  */
249 static  int day_map[] = {
250         0,
251         0,
252         0,
253         6,      /* 3 - Sat */
254         4,      /* 4 - Thu */
255         0,
256         5,      /* 6 - Fri */
257         0,      /* 7 - Sun */
258         2,      /* 8 - Tue */
259         1       /* 9 - Mon */,
260         0,
261         3       /*11 - Wed */
262 };
263 #define SETDAY  { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)];\
264                 tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP;\
265                 cp += 2; }
266 #define SETMONTH { tw.tw_mon = month_map[(cp[0] + cp[1]) & 0x1f]; gotdate++;\
267                  cp += 2;\
268                  SKIPD;}
269 #define CVT1OR2 (i=(*cp++ - '0'), isdigit(*cp)? i*10 + (*cp++ - '0') : i)
270 #define CVT2      ((cp[0] - '0')*10 + (cp[1] - '0'))
271 #define CVT4    ((((cp[0] - '0')*10 + (cp[1] - '0'))*10 + \
272                                       (cp[2] - '0'))*10 + (cp[3] - '0'))
273 #define SKIPD   { while ( !isdigit(*cp++) ) ;  --cp; }
274 #define EXPZONE { tw.tw_flags &= ~TW_SZONE; tw.tw_flags |= TW_SZEXP; }
275 #define ZONE(x) { tw.tw_zone=(x); EXPZONE; }
276 #define ZONED(x) { ZONE(x); tw.tw_flags |= TW_DST; }
277 #define LC(c)   (isupper (c) ? tolower (c) : (c))
278
279 #ifdef  DSTXXX
280 #ifdef  _AIX
281 #include <sys/time.h>
282 #include <time.h>
283 #else
284 #ifndef BSD42
285 #include <time.h>
286 #else   /* BSD42 */
287 #include <sys/time.h>
288 #endif  /* BSD42 */
289 #endif
290
291 static  zonehack (tw)
292 register struct tws *tw;
293 {
294     register struct tm *tm;
295
296     if (twclock (tw) == -1L)
297         return;
298
299     tm = localtime (&tw -> tw_clock);
300     if (tm -> tm_isdst) {
301         tw -> tw_flags |= TW_DST;
302         tw -> tw_zone -= 60;
303     }
304 }
305 #endif  /* DSTXXX */
306 %}
307 %%
308 %{
309 struct tws *dparsetime (str)
310         char *str;
311 {
312         register int i;
313         static struct tws tw;
314         register char *cp;
315         register int gotdate = 0;
316 #ifndef SYS5
317 #ifdef ZONEINFO
318         struct tm      *tm;
319         time_t          clock;
320 #else
321         struct timeb    tb;
322 #endif  /* ZONEINFO */
323 #endif  /* not SYS5 */
324         long tclock;
325
326         start_cond = 0;
327
328         /* Zero out the struct. */
329         bzero( (char *) &tw, sizeof tw);
330
331         /* Set default time zone. */
332 #ifdef SYS5
333         tzset( );
334         tw.tw_zone = -(timezone / 60);
335 #else
336 #ifdef ZONEINFO
337         time (&clock);
338         tm = localtime(&clock);
339         tw.tw_zone = tm->tm_gmtoff / 60;
340         if (tm -> tm_isdst)                     /* if DST is in effect */
341                 tw.tw_zone -= 60;               /* reset to normal offset */
342 #else
343         ftime( &tb );
344         tw.tw_zone = -tb.timezone;
345 #endif  /* ZONEINFO */
346 #endif  /* SYS5 */
347
348         while (isspace(*str))
349                 str++;
350         while ( 1 )
351                 switch (cp = str, *cp ? lex_string( &str, start_cond) : 0) {
352
353                 case -1:
354                         if (!gotdate || tw.tw_year == 0)
355                                 return (struct tws *)0;
356                         /* fall through */
357                 case 0:
358                         if ( tw.tw_year == 0 ) {
359                                 /* Set default year. */
360                                 time (&tclock);
361                                 tw.tw_year = localtime(&tclock)->tm_year + 1900;
362                         }
363                         else if (tw.tw_year < 100) {
364                                 /* assume no 2-digit years > 1999 */
365                                 tw.tw_year += 1900;
366                         }
367                         return &tw;
368
369 %}
370 {DAY}","?{w}                            SETDAY;
371 "("{DAY}")"(","?)                       {
372                                         cp++;
373                                         SETDAY;
374                                         }
375 {D}(("-"{D}"-")|("/"{D}"/")){D}?{d}{d}{w}       {
376                                         if (europeandate) {
377                                                 /* European: DD/MM/YY */
378                                                 tw.tw_mday = CVT1OR2;
379                                                 cp++;
380                                                 tw.tw_mon  = CVT1OR2 - 1;
381                                         } else {
382                                                 /* American: MM/DD/YY */
383                                                 tw.tw_mon  = CVT1OR2 - 1;
384                                                 cp++;
385                                                 tw.tw_mday = CVT1OR2;
386                                         }
387                                         cp++;
388                                         for (i = 0; isdigit(*cp); )
389                                                 i = i*10 + (*cp++ - '0');
390                                         tw.tw_year = i;
391                                         gotdate++;      /* XXX */
392                                         }
393 {D}("/"|"-"){D}{w}                      {
394                                         if (europeandate) {
395                                                 tw.tw_mday = CVT1OR2; cp++;
396                                                 tw.tw_mon  = CVT1OR2 - 1;
397                                         } else {
398                                                 tw.tw_mon = CVT1OR2 - 1; cp++;
399                                                 tw.tw_mday  = CVT1OR2;
400                                         }
401                                         gotdate++;
402                                         }
403 {D}{w}(-)?{w}{MONTH}{w}(-)?{w}{D}?{d}{d}({W}at)?{w}     {
404                                         tw.tw_mday = CVT1OR2;
405                                         while ( !isalpha(*cp++) )
406                                                 ;
407                                         SETMONTH;
408                                         for (i = 0; isdigit(*cp); )
409                                                 i = i*10 + (*cp++ - '0');
410                                         tw.tw_year = i;
411                                         }
412 {D}"-"?{MONTH}({W}at)?{w}               {
413                                         tw.tw_mday = CVT1OR2;
414                                         while ( ! isalpha( *cp++ ) )
415                                                 ;
416                                         SETMONTH;
417                                         }
418 {MONTH}{W}{D}","{W}{D}?{d}{d}{w}        {
419                                         cp++;
420                                         SETMONTH;
421                                         tw.tw_mday = CVT1OR2;
422                                         SKIPD;
423                                         for (i = 0; isdigit(*cp); )
424                                                 i = i*10 + (*cp++ - '0');
425                                         tw.tw_year = i;
426                                         }
427 {MONTH}{W}{D}{w}                        {
428                                         cp++;
429                                         SETMONTH;
430                                         tw.tw_mday = CVT1OR2;
431                                         }
432
433 {D}:{D}:{D}{W}19[6-9]{d}                {       /* hack: ctime w/o TZ */
434                                         tw.tw_hour = CVT1OR2; cp++;
435                                         tw.tw_min  = CVT1OR2; cp++;
436                                         tw.tw_sec  = CVT1OR2;
437                                         SKIPD;
438                                         tw.tw_year = CVT4; cp+=4;
439                                         }
440 {D}:{D}:{D}{w}                          {
441                                         tw.tw_hour = CVT1OR2; cp++;
442                                         tw.tw_min  = CVT1OR2; cp++;
443                                         tw.tw_sec  = CVT1OR2;
444                                         BEGIN Z;
445                                         }
446 {D}:{D}{w}                              {
447                                         tw.tw_hour = CVT1OR2; cp++;
448                                         tw.tw_min = CVT1OR2;
449                                         BEGIN Z;
450                                         }
451 {D}:{D}{w}am{w}                         {
452                                         tw.tw_hour = CVT1OR2; cp++;
453                                         if (tw.tw_hour == 12)
454                                                 tw.tw_hour = 0;
455                                         tw.tw_min  = CVT1OR2;
456                                         BEGIN Z;
457                                         }
458 {D}:{D}:{D}{w}am{w}                     {
459                                         tw.tw_hour = CVT1OR2; cp++;
460                                         if (tw.tw_hour == 12)
461                                                 tw.tw_hour = 0;
462                                         tw.tw_min  = CVT1OR2; cp++;
463                                         tw.tw_sec  = CVT1OR2;
464                                         BEGIN Z;
465                                         }
466 {D}:{D}{w}pm{w}                         {
467                                         tw.tw_hour = CVT1OR2; cp++;
468                                         if (tw.tw_hour != 12)
469                                                 tw.tw_hour += 12;
470                                         tw.tw_min  = CVT1OR2;
471                                         BEGIN Z;
472                                         }
473 {D}:{D}:{D}{w}pm{w}                     {
474                                         tw.tw_hour = CVT1OR2; cp++;
475                                         if (tw.tw_hour != 12)
476                                                 tw.tw_hour += 12;
477                                         tw.tw_min  = CVT1OR2; cp++;
478                                         tw.tw_sec  = CVT1OR2;
479                                         BEGIN Z;
480                                         }
481 [0-2]{d}{d}{d}{d}{d}{w}                 {
482                                         tw.tw_hour = CVT2; cp+=2;
483                                         tw.tw_min  = CVT2; cp+=2;
484                                         tw.tw_sec  = CVT2; cp+=2;
485                                         BEGIN Z;
486                                         }
487 19[6-9]{d}{w}                           {
488                                         /*
489                                          * Luckly, 4 digit times in the range
490                                          * 1960-1999 aren't legal as hour
491                                          * and minutes.
492                                          */
493                                         tw.tw_year = CVT4; cp+=4;
494                                         }
495 [0-2]{d}{d}{d}{w}                       {
496                                         if (tw.tw_hour || tw.tw_min 
497                                                             || tw.tw_sec) {
498                                             tw.tw_year = CVT4; cp+=4;
499                                             tw.tw_zone = 0;
500                                         } else {
501                                             tw.tw_hour = CVT2; cp+=2;
502                                             tw.tw_min  = CVT2; cp+=2;
503                                             BEGIN Z;
504                                         }
505                                         }
506 <Z>"-"?ut                               ZONE(0 * 60);
507 <Z>"-"?gmt                              ZONE(0 * 60);
508 <Z>"-"?jst                              ZONE(2 * 60);
509 <Z>"-"?jdt                              ZONED(2 * 60);
510 <Z>"-"?est                              ZONE(-5 * 60);
511 <Z>"-"?edt                              ZONED(-5 * 60);
512 <Z>"-"?cst                              ZONE(-6 * 60);
513 <Z>"-"?cdt                              ZONED(-6 * 60);
514 <Z>"-"?mst                              ZONE(-7 * 60);
515 <Z>"-"?mdt                              ZONED(-7 * 60);
516 <Z>"-"?pst                              ZONE(-8 * 60);
517 <Z>"-"?pdt                              ZONED(-8 * 60);
518 <Z>"-"?nst                              ZONE(-(3 * 60 + 30));
519 <Z>"-"?ast                              ZONE(-4 * 60);
520 <Z>"-"?adt                              ZONED(-4 * 60);
521 <Z>"-"?yst                              ZONE(-9 * 60);
522 <Z>"-"?ydt                              ZONED(-9 * 60);
523 <Z>"-"?hst                              ZONE(-10 * 60);
524 <Z>"-"?hdt                              ZONED(-10 * 60);
525 <Z>"-"?bst                              ZONED(-1 * 60);
526 <Z>[a-i]                                {
527                                         tw.tw_zone = 60 * (('a'-1) - LC(*cp));
528                                         EXPZONE; 
529                                         }
530 <Z>[k-m]                                {
531                                         tw.tw_zone = 60 * ('a' - LC(*cp));
532                                         EXPZONE; 
533                                         }
534 <Z>[n-y]                                {
535                                         tw.tw_zone = 60 * (LC(*cp) - 'm');
536                                         EXPZONE; 
537                                         }
538 <Z>"+"[0-1]{d}{d}{d}                    {
539                                         cp++;
540                                         tw.tw_zone = ((cp[0] * 10 + cp[1])
541                                                      -('0' * 10   + '0'))*60
542                                                     +((cp[2] * 10 + cp[3])
543                                                      -('0' * 10   + '0'));
544                                         EXPZONE;
545 #ifdef  DSTXXX
546                                         zonehack (&tw);
547 #endif  /* DSTXXX */
548                                         cp += 4;
549                                         }
550 <Z>"-"[0-1]{d}{d}{d}                    {
551                                         cp++;
552                                         tw.tw_zone = (('0' * 10   + '0')
553                                                      -(cp[0] * 10 + cp[1]))*60
554                                                     +(('0' * 10   + '0')
555                                                      -(cp[2] * 10 + cp[3]));
556                                         EXPZONE;
557 #ifdef  DSTXXX
558                                         zonehack (&tw);
559 #endif  /* DSTXXX */
560                                         cp += 4;
561                                         }
562 <Z>{W}{d}{d}{d}{d}                      {
563                                         SKIPD;
564                                         tw.tw_year = CVT4; cp+=4;
565                                         }
566 \n      |
567 {W}     ;
568 %%
569 @
570
571
572 2.14
573 log
574 @endif sugar
575 @
576 text
577 @d37 1
578 a37 1
579 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.13 1992/05/19 21:26:05 jromine Exp jromine $";
580 d43 1
581 a43 1
582 #ifndef SYS5
583 d45 1
584 a45 1
585 #endif /* not SYS5 */
586 d171 4
587 d176 2
588 a177 1
589 #endif /* not SYS5 */
590 d186 11
591 a196 1
592 #ifndef SYS5
593 d199 2
594 a200 4
595 #else /* SYS5 */
596         tzset( );
597         tw.tw_zone = -(timezone / 60);
598 #endif /* SYS5 */
599 @
600
601
602 2.13
603 log
604 @AIX
605 @
606 text
607 @d37 1
608 a37 1
609 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.12 1992/05/19 21:25:17 jromine Exp jromine $";
610 d45 1
611 a45 1
612 #endif not SYS5
613 d51 1
614 a51 1
615 #endif SYS5
616 d140 1
617 a140 1
618 #else   BSD42
619 d142 1
620 a142 1
621 #endif  BSD42
622 d159 1
623 a159 1
624 #endif  DSTXXX
625 d172 1
626 a172 1
627 #endif not SYS5
628 d184 1
629 a184 1
630 #else SYS5
631 d187 1
632 a187 1
633 #endif SYS5
634 d388 1
635 a388 1
636 #endif  DSTXXX
637 d400 1
638 a400 1
639 #endif  DSTXXX
640 @
641
642
643 2.12
644 log
645 @4-year dates
646 @
647 text
648 @d37 1
649 a37 1
650 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.11 1992/02/10 20:32:29 jromine Exp jromine $";
651 d134 4
652 d143 1
653 @
654
655
656 2.11
657 log
658 @clock -> tclock
659 @
660 text
661 @d37 1
662 a37 1
663 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.10 1992/02/09 22:41:24 jromine Exp jromine $";
664 d124 3
665 a126 4
666 #define CVT2    ((*cp++ - '0')*10 + (*cp++ - '0'))
667 #define CVT3    (((*cp++ - '0')*10 + (*cp++ - '0'))*10 + (*cp++ - '0'))
668 #define CVT4    ((((*cp++ - '0')*10 + (*cp++ - '0'))*10 + \
669                                 (*cp++ - '0'))*10 + (*cp++ - '0'))
670 d274 1
671 a274 1
672                                         tw.tw_year = CVT4;
673 d318 3
674 a320 3
675                                         tw.tw_hour = CVT2;
676                                         tw.tw_min  = CVT2;
677                                         tw.tw_sec  = CVT2;
678 d329 1
679 a329 1
680                                         tw.tw_year = CVT4;
681 d334 1
682 a334 1
683                                             tw.tw_year = CVT4;
684 d337 2
685 a338 2
686                                             tw.tw_hour = CVT2;
687                                             tw.tw_min  = CVT2;
688 d400 1
689 a400 1
690                                         tw.tw_year = CVT4;
691 @
692
693
694 2.10
695 log
696 @make all years 4-digit
697 @
698 text
699 @d37 1
700 a37 1
701 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.9 1992/02/07 01:04:07 jromine Exp jromine $";
702 d169 1
703 a169 1
704         long clock;
705 d197 2
706 a198 2
707                                 time( &clock );
708                                 tw.tw_year = localtime(&clock)->tm_year + 1900;
709 @
710
711
712 2.9
713 log
714 @typo
715 @
716 text
717 @d37 1
718 a37 1
719 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.8 1992/02/07 00:46:23 jromine Exp jromine $";
720 d199 4
721 @
722
723
724 2.8
725 log
726 @fix
727 @
728 text
729 @d37 1
730 a37 1
731 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.7 1992/02/07 00:45:31 jromine Exp jromine $";
732 d236 1
733 a236 1
734 {D}{w}(-)?{w}{MONTH}{w}(-){w}{D}?{d}{d}({W}at)?{w}      {
735 @
736
737
738 2.7
739 log
740 @4 digit years
741 @
742 text
743 @d37 1
744 a37 1
745 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.6 1992/02/07 00:25:45 jromine Exp $";
746 d198 1
747 a198 3
748                                 tw.tw_year = localtime( &clock ) -> tm_year;
749                                 if (tw.tw_year < 100)
750                                     tw.tw_year += CENTURY;
751 @
752
753
754 2.6
755 log
756 @fixes
757 @
758 text
759 @d37 1
760 a37 1
761 static char ident[] = "@@(#)$Id: dtimep.lex,v 2.5 1992/02/07 00:10:21 jromine Exp jromine $";
762 d199 2
763 @
764
765
766 2.5
767 log
768 @merge done
769 @
770 text
771 @d37 1
772 a37 1
773 static char ident[] = "@@(#)$Id: dtimep.lex,v 1.10 1990/04/05 15:55:07 sources Exp $";
774 d236 1
775 a236 1
776 {D}(("-"{MONTH}"-")|(" "{MONTH}" ")|({MONTH})){D}?{d}{d}({W}at)?{w}     {
777 d271 1
778 a271 1
779                                         tw.tw_year = CVT1OR2;
780 @
781
782
783 2.4
784 log
785 @more patches
786 @
787 text
788 @d245 6
789 @
790
791
792 2.3
793 log
794 @more patches
795 @
796 text
797 @a243 1
798                                         gotdate++;      /* XXX */
799 a252 1
800                                         gotdate++;      /* XXX */
801 a257 1
802                                         gotdate++;      /* XXX */
803 d323 3
804 a325 3
805                                         if (tw.tw_hour) {
806                                             cp += 2;
807                                             tw.tw_year = CVT2;
808 @
809
810
811 2.2
812 log
813 @more patches
814 @
815 text
816 @d264 5
817 a268 7
818                                         tw.tw_hour = CVT2; cp++;
819                                         tw.tw_min  = CVT2; cp++;
820                                         tw.tw_sec  = CVT2;
821                                         while( !isdigit(*cp++) )
822                                                 ;
823                                         cp++;
824                                         tw.tw_year = CVT2;
825 @
826
827
828 2.1
829 log
830 @more diffs
831 @
832 text
833 @d236 1
834 a236 1
835 {D}{w}(-)?{w}{MONTH}{w}(-)?{w}(19)?{D}{w}(\,{w}|at{W})? {
836 d243 2
837 a244 1
838                                         tw.tw_year = i % 100;
839 @
840
841
842 2.0
843 log
844 @start merging changes from the Jef Poskanzer version
845 @
846 text
847 @d123 5
848 a127 1
849 #define CVT2    (i=(*cp++ - '0'),isdigit(*cp)? i*10 + (*cp++ - '0') : i)
850 d226 10
851 d272 3
852 a274 3
853                                         tw.tw_hour = CVT2; cp++;
854                                         tw.tw_min  = CVT2; cp++;
855                                         tw.tw_sec  = CVT2;
856 d278 2
857 a279 2
858                                         tw.tw_hour = CVT2; cp++;
859                                         tw.tw_min = CVT2;
860 d283 1
861 a283 1
862                                         tw.tw_hour = CVT2; cp++;
863 d286 1
864 a286 1
865                                         tw.tw_min  = CVT2;
866 d289 8
867 d298 1
868 a298 1
869                                         tw.tw_hour = CVT2; cp++;
870 d301 1
871 a301 1
872                                         tw.tw_min  = CVT2;
873 d304 8
874 d324 1
875 a324 2
876                                         cp += 2;
877                                         tw.tw_year = CVT2;
878 @
879
880
881 1.10
882 log
883 @Id
884 @
885 text
886 @d37 1
887 a37 1
888 static char ident[] = "@@(#)$Id:$";
889 d165 1
890 d188 1
891 a188 1
892                                 return 0;
893 d191 5
894 d204 1
895 a204 1
896 {D}"/"{D}"/"(19)?[0-9][0-9]{w}          {
897 d207 1
898 a207 1
899                                                 tw.tw_mday = CVT2;
900 d209 1
901 a209 1
902                                                 tw.tw_mon  = CVT2 - 1;
903 d212 1
904 a212 1
905                                                 tw.tw_mon  = CVT2 - 1;
906 d214 1
907 a214 1
908                                                 tw.tw_mday = CVT2;
909 d219 2
910 a220 1
911                                         tw.tw_year = i % 100;
912 d223 1
913 a223 1
914                                         tw.tw_mday = CVT2;
915 d231 1
916 a231 1
917 {MONTH}{W}{D}","{W}(19)?{D}{w}          {
918 d234 1
919 a234 1
920                                         tw.tw_mday = CVT2;
921 d238 2
922 a239 1
923                                         tw.tw_year = i % 100;
924 a240 1
925
926 d244 2
927 a245 1
928                                         tw.tw_mday = CVT2;
929 d327 1
930 a327 1
931 <Z>"-"?bst                              ZONED(0 * 60);
932 d364 3
933 a366 5
934 <Z>{W}19[6-9]{d}                        {
935                                         while( !isdigit(*cp++) )
936                                                 ;
937                                         cp++;
938                                         tw.tw_year = CVT2;
939 a367 1
940
941 @
942
943
944 1.9
945 log
946 @fix for numeric tz parsing
947 @
948 text
949 @d36 3
950 @
951
952
953 1.8
954 log
955 @many changes to make parsing more lax.
956 @
957 text
958 @d290 1
959 a290 1
960                                             tw.tw_zone = ZONE(0 * 60);/* GMT */
961 d335 1
962 d347 1
963 @
964
965
966 1.7
967 log
968 @UCL fix
969 @
970 text
971 @d51 8
972 d114 4
973 a117 4
974 #define SETDAY  tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)];\
975                 tw.tw_flags |= TW_SEXP;\
976                 cp += 2;
977 #define SETMONTH tw.tw_mon = month_map[(cp[0] + cp[1]) & 0x1f]; gotdate++;\
978 d119 1
979 a119 1
980                  SKIPD;
981 d121 4
982 a124 3
983 #define SKIPD   while ( !isdigit(*cp++) ) ;  --cp;
984 #define ZONE(x) tw.tw_zone=(x);
985 #define ZONED(x)  tw.tw_zone=(x); tw.tw_flags |= TW_DST;
986 d177 2
987 d180 1
988 a180 1
989                 switch (cp = str, lex_string( &str, start_cond)) {
990 d191 3
991 a193 7
992 "("{DAY}")"(","?)                       cp++, SETDAY;
993
994 {D}"/"{D}"/"19[0-9][0-9]{w}             {
995                                         tw.tw_mday = CVT2; cp++;
996                                         tw.tw_mon  = CVT2 - 1; cp += 3;
997                                         tw.tw_year = CVT2;
998                                         gotdate++;
999 d195 11
1000 a205 5
1001 {D}"/"{D}"/"[0-9][0-9]{w}               {
1002                                         tw.tw_mday = CVT2; cp++;
1003                                         tw.tw_mon  = CVT2 - 1; cp++;
1004                                         tw.tw_year = CVT2;
1005                                         gotdate++;
1006 d207 6
1007 a212 1
1008 {D}("-"|{W})?{MONTH}("-"|{W})?(19)?{D}({W}at{W})?       {
1009 d277 9
1010 d317 12
1011 a328 3
1012 <Z>[a-i]                                tw.tw_zone = 60 * (('a'-1) - LC (*cp));
1013 <Z>[k-m]                                tw.tw_zone = 60 * ('a' - LC (*cp));
1014 <Z>[n-y]                                tw.tw_zone = 60 * (LC (*cp) - 'm');
1015 @
1016
1017
1018 1.6
1019 log
1020 @allow lwsp between digits and month name
1021 @
1022 text
1023 @d289 1
1024 a289 1
1025 <Z>"-"?bst                              ZONED(-1 * 60);
1026 @
1027
1028
1029 1.5
1030 log
1031 @move zonehack() routine to top
1032 @
1033 text
1034 @d194 1
1035 a194 1
1036 {D}[- ]?{MONTH}[- ]?(19)?{D}({W}at{W})? {
1037 @
1038
1039
1040 1.4
1041 log
1042 @fix for dates with no timezone
1043 @
1044 text
1045 @a43 8
1046 #ifdef  DSTXXX
1047 #ifndef BSD42
1048 #include <time.h>
1049 #else   BSD42
1050 #include <sys/time.h>
1051 #endif  BSD42
1052 #endif  DSTXXX
1053
1054 d117 23
1055 a139 1
1056 static zonehack();
1057 d269 1
1058 a324 17
1059 #ifdef  DSTXXX
1060
1061 static  zonehack (tw)
1062 register struct tws *tw;
1063 {
1064     register struct tm *tm;
1065
1066     if (twclock (tw) == -1L)
1067         return;
1068
1069     tm = localtime (&tw -> tw_clock);
1070     if (tm -> tm_isdst) {
1071         tw -> tw_flags |= TW_DST;
1072         tw -> tw_zone -= 60;
1073     }
1074 }
1075 #endif  DSTXXX
1076 @
1077
1078
1079 1.3
1080 log
1081 @ANSI Compilance
1082 @
1083 text
1084 @d246 8
1085 a253 3
1086                                         tw.tw_hour = CVT2;
1087                                         tw.tw_min  = CVT2;
1088                                         BEGIN Z;
1089 @
1090
1091
1092 1.2
1093 log
1094 @move some #include up a bit
1095 @
1096 text
1097 @d125 1
1098 @
1099
1100
1101 1.1
1102 log
1103 @Initial revision
1104 @
1105 text
1106 @d44 8
1107 a304 5
1108 #ifndef BSD42
1109 #include <time.h>
1110 #else   BSD42
1111 #include <sys/time.h>
1112 #endif  BSD42
1113 @