};
/*
- * 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,
*/
#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++; \
--cp; }
#define SKIPTOSP() { while ( !isspace(*cp++) ) ; \
--cp; }
+
+#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
+# ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+# else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# 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)?)
INIT();
SKIPTOD();
SETZONE(atoi(cp));
+#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
+ zonehack (&tw);
+#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
}
"-"{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 */
}
"-"?("ut"|"UT") INIT(); SETZONE(0);
"-"?("gmt"|"GMT") INIT(); SETZONE(0);