X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fdtimep.lex;h=a228694940511863cabb3d96e1a8dcadd9d05d0d;hp=4f019808c42d844a1643e0856c56c1b493a7170e;hb=1513f7668c494c4583141d6115669b7198c14556;hpb=859187428420e9089e91a45f3a833135172d1822 diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 4f01980..a228694 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -1,7 +1,3 @@ -%e 2000 -%p 5000 -%n 1000 -%a 4000 %{ #include #include @@ -32,9 +28,9 @@ if(!(tw.tw_flags & TW_SUCC)) { \ return (struct tws *)NULL; \ } \ - if(tw.tw_year < 1960) \ + if(tw.tw_year < 1970) \ tw.tw_year += 1900; \ - if(tw.tw_year < 1960) \ + if(tw.tw_year < 1970) \ tw.tw_year += 100; \ return(&tw) @@ -86,8 +82,10 @@ static int month_map[] = { }; /* - * Same trick for day-of-week using the hash function - * (c1 & 7) + (c2 & 4) + * Lookup table for day-of-week using the same hash trick as for above name-of- + * month table, but using the first and second character, not second and third. + * + * Compute index into table using: (day_name[0] & 7) + (day_name[1] & 4) */ static int day_map[] = { 0, @@ -115,8 +113,7 @@ static int day_map[] = { */ #define INIT() { cp = yytext;} -#define SETWDAY() { cp++; \ - tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)]; \ +#define SETWDAY() { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)]; \ tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; \ SKIPA(); } #define SETMON() { cp++; \ @@ -152,6 +149,34 @@ static int day_map[] = { --cp; } #define SKIPTOSP() { while ( !isspace(*cp++) ) ; \ --cp; } + +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST +# ifdef TIME_WITH_SYS_TIME +# include +# include +# else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +# endif + +static void +zonehack (struct tws *tw) +{ + register struct tm *tm; + + if (dmktime (tw) == (time_t) -1) + return; + + tm = localtime (&tw->tw_clock); + if (tm->tm_isdst) { + tw->tw_flags |= TW_DST; + tw->tw_zone -= 60; + } +} +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ %} sun ([Ss]un(day)?) @@ -193,6 +218,7 @@ w ([ \t]*) W ([ \t]+) D ([0-9]?[0-9]) d [0-9] +nl [ \t\n()] %% %{ @@ -326,42 +352,40 @@ d [0-9] INIT(); SKIPTOD(); SETZONE(atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ + yyterminate(); } "-"{D}{d}{d} { INIT(); SKIPTOD(); SETZONE(-atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ + yyterminate(); + } -"-"?("ut"|"UT") INIT(); SETZONE(0); -"-"?("gmt"|"GMT") INIT(); SETZONE(0); -"-"?("jst"|"JST") INIT(); SETZONE(200); -"-"?("jdt"|"JDT") INIT(); SETDST(); SETZONE(2); -"-"?("est"|"EST") INIT(); SETZONE(-500); -"-"?("edt"|"EDT") INIT(); SETDST(); SETZONE(-500); -"-"?("cst"|"CST") INIT(); SETZONE(-600); -"-"?("cdt"|"CDT") INIT(); SETDST(); SETZONE(-600); -"-"?("mst"|"MST") INIT(); SETZONE(-700); -"-"?("mdt"|"MDT") INIT(); SETDST(); SETZONE(-700); -"-"?("pst"|"PST") INIT(); SETZONE(-800); -"-"?("pdt"|"PDT") INIT(); SETDST(); SETZONE(-800); -"-"?("nst"|"NST") INIT(); SETZONE(-330); -"-"?("ast"|"AST") INIT(); SETZONE(-400); -"-"?("adt"|"ADT") INIT(); SETDST(); SETZONE(-400); -"-"?("yst"|"YST") INIT(); SETZONE(-900); -"-"?("ydt"|"YDT") INIT(); SETDST(); SETZONE(-900); -"-"?("hst"|"HST") INIT(); SETZONE(-1000); -"-"?("hdt"|"HDT") INIT(); SETDST(); SETZONE(-1000); -"-"?("bst"|"BST") INIT(); SETDST(); SETZONE(-100); -[a-iA-I] { - INIT(); - SETZONE(100*(('a'-1) - tolower(*cp))); - } -[k-mK-M] { - INIT(); - SETZONE(100*('a' - tolower(*cp))); - } -[n-yN-Y] { - INIT(); - SETZONE(100*(tolower(*cp) - 'm')); - } +{nl}("ut"|"UT") INIT(); SETZONE(0); yyterminate(); +{nl}("gmt"|"GMT") INIT(); SETZONE(0); yyterminate(); +{nl}("est"|"EST") INIT(); SETZONE(-500); yyterminate(); +{nl}("edt"|"EDT") { INIT(); SETDST(); SETZONE(-500); + yyterminate(); } +{nl}("cst"|"CST") INIT(); SETZONE(-600); yyterminate(); +{nl}("cdt"|"CDT") { INIT(); SETDST(); SETZONE(-600); + yyterminate(); } +{nl}("mst"|"MST") INIT(); SETZONE(-700); yyterminate(); +{nl}("mdt"|"MDT") { INIT(); SETDST(); SETZONE(-700); + yyterminate(); } +{nl}("pst"|"PST") INIT(); SETZONE(-800); yyterminate(); +{nl}("pdt"|"PDT") { INIT(); SETDST(); SETZONE(-800); + yyterminate(); } +{nl}("nst"|"NST") INIT(); SETZONE(-330); yyterminate(); +{nl}("ast"|"AST") INIT(); SETZONE(-400); yyterminate(); +{nl}("adt"|"ADT") { INIT(); SETDST(); SETZONE(-400); + yyterminate(); } +{nl}("hst"|"HST") INIT(); SETZONE(-1000); yyterminate(); +{nl}("hdt"|"HDT") { INIT(); SETDST(); SETZONE(-1000); + yyterminate(); } .|\n