*/
int europeandate = 0;
-static char *monthnames[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- NULL
-};
-
-static char *daynames[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
-};
-
static int
name2num(char *name, char *names[])
{
*/
#define INIT() { cp = yytext;}
-#define SETWDAY() { tw.tw_wday = name2num(cp, daynames); \
+#define SETWDAY() { tw.tw_wday = name2num(cp, tw_dotw); \
tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; SKIPA(); }
-#define SETMON() { tw.tw_mon = name2num(cp, monthnames); SKIPA(); }
+#define SETMON() { tw.tw_mon = name2num(cp, tw_moty); SKIPA(); }
#define SETMON_NUM() { tw.tw_mon = atoi(cp)-1; SKIPD(); }
#define SETYEAR() { tw.tw_year = atoi(cp); SKIPD(); }
#define SETDAY() { tw.tw_mday = atoi(cp); tw.tw_flags |= TW_YES; SKIPD(); }
tw.tw_sec = atoi(++cp); SKIPD(); } }
#define SETZONE(x) { tw.tw_zone = ((x)/100)*60+(x)%100; \
tw.tw_flags |= TW_SZEXP; SKIPD(); }
+#define SETZONEC(h, m) { tw.tw_zone = (h)*60+(m); \
+ tw.tw_flags |= TW_SZEXP; SKIPD(); }
#define SETDST() { tw.tw_flags |= TW_DST; }
#define SKIPD() { while ( isdigit(*cp++) ) ; --cp; }
#define SKIPTOD() { while ( !isdigit(*cp++) ) ; --cp; }
#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
%}
-sun ([Ss]un(day)?)
-mon ([Mm]on(day)?)
-tue ([Tt]ue(sday)?)
-wed ([Ww]ed(nesday)?)
-thu ([Tt]hu(rsday)?)
-fri ([Ff]ri(day)?)
-sat ([Ss]at(urday)?)
+sun ([Ss][Uu][Nn]([Dd][Aa][Yy])?)
+mon ([Mm][Oo][Nn]([Dd][Aa][Yy])?)
+tue ([Tt][Uu][Ee]([Ss][Dd][Aa][Yy])?)
+wed ([Ww][Ee][Dd]([Nn][Ee][Ss][Dd][Aa][Yy])?)
+thu ([Tt][Hh][Uu]([Rr][Ss][Dd][Aa][Yy])?)
+fri ([Ff][Rr][Ii]([Dd][Aa][Yy])?)
+sat ([Ss][Aa][Tt]([Uu][Rr][Dd][Aa][Yy])?)
DAY ({sun}|{mon}|{tue}|{wed}|{thu}|{fri}|{sat})
-jan ([Jj]an(uary)?)
-feb ([Ff]eb(ruary)?)
-mar ([Mm]ar(ch)?)
-apr ([Aa]pr(il)?)
-may ([Mm]ay)
-jun ([Jj]un(e)?)
-jul ([Jj]ul(y)?)
-aug ([Aa]ug(ust)?)
-sep ([Ss]ep(tember)?)
-oct ([Oo]ct(ober)?)
-nov ([Nn]ov(ember)?)
-dec ([Dd]ec(ember)?)
+jan ([Jj][Aa][Nn]([Uu][Aa][Rr][Yy])?)
+feb ([Ff][Ee][Bb]([Rr][Uu][Aa][Rr][Yy])?)
+mar ([Mm][Aa][Rr]([Cc][Hh])?)
+apr ([Aa][Pp][Rr]([Ii][Ll])?)
+may ([Mm][Aa][Yy])
+jun ([Jj][Uu][Nn]([Ee])?)
+jul ([Jj][Uu][Ll]([Yy])?)
+aug ([Aa][Uu][Gg]([Uu][Ss][Tt])?)
+sep ([Ss][Ee][Pp]([Tt][Ee][Mm][Bb][Ee][Rr])?)
+oct ([Oo][Cc][Tt]([Oo][Bb][Ee][Rr])?)
+nov ([Nn][Oo][Vv]([Ee][Mm][Bb][Ee][Rr])?)
+dec ([Dd][Ee][Cc]([Ee][Mm][Bb][Ee][Rr])?)
MONTH ({jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec})
SKIPTOD();
SETYEAR();
}
-{D}("-"|"/"){D}("-"|"/"){YEAR}{W}{TIME} {
+{d}{4}"-"{d}{2}"-"{d}{2}(" "|"T"){TIME} {
+ INIT();
+ SETYEAR();
+ SKIPTOD();
+ SETMON_NUM();
+ SKIPTOD();
+ SETDAY();
+ SKIPTOD();
+ SETTIME();
+}
+{d}{4}"-"{d}{2}"-"{d}{2} {
+ INIT();
+ SETYEAR();
+ SKIPTOD();
+ SETMON_NUM();
+ SKIPTOD();
+ SETDAY();
+}
+{d}{2}"-"{d}{2}"-"{d}{2} {
+ fprintf(stderr, "the highly ambiguous date format XX-XX-XX..."
+ " is no longer supported\n");
+}
+{D}"/"{D}"/"{YEAR}{W}{TIME} {
INIT();
if(europeandate) {
/* DD/MM/YY */
SKIPTOD();
SETTIME();
}
-{D}("-"|"/"){D}("-"|"/"){YEAR} {
+{D}"/"{D}"/"{YEAR} {
INIT();
if(europeandate) {
/* DD/MM/YY */
yyterminate();
}
+"+"{d}{d}":"{d}{d} {
+ INIT();
+ SKIPTOD();
+ SETZONEC(atoi(cp), atoi(cp+3));
+#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
+ zonehack (&tw);
+#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
+ yyterminate();
+}
+"-"{d}{d}":"{d}{d} {
+ INIT();
+ SKIPTOD();
+ SETZONEC(-atoi(cp), -atoi(cp+3));
+#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
+ zonehack (&tw);
+#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
+ yyterminate();
+
+}
{nl}("ut"|"UT") INIT(); SETZONE(0); yyterminate();
{nl}("gmt"|"GMT") INIT(); SETZONE(0); yyterminate();
{nl}("est"|"EST") INIT(); SETZONE(-500); yyterminate();