[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] Re: shellutils: date -d 'last june' +'%B %Y' -> May 2004
From: |
Paul Eggert |
Subject: |
[Bug-gnulib] Re: shellutils: date -d 'last june' +'%B %Y' -> May 2004 |
Date: |
Tue, 16 Nov 2004 00:29:00 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Jim Meyering <address@hidden> writes:
> http://bugs.debian.org/281004
Dates like "last June" never worked as people expected. "last" was
equivalent to "-1", so "last june" was parsed as "-1 june", which was
equivalent to "30 May", which explains the symptoms the original bug
reporter observed.
Fortunately (:-), these dates weren't documented either. For now, I
installed the following patch into both gnulib and coreutils; it
causes "last june" to be rejected as a syntax error. If someone wants
to add support for this usage that'd be even better.
2004-11-16 Paul Eggert <address@hidden>
* doc/getdate.texi (General date syntax): "next" is 1, not 2.
Document that "second" isn't allowed as an ordinal number.
* lib/getdate.y (tORDINAL): New token.
(day, relunit): Allow it for relative times.
(relative_time_table): Use tORDINAL for ordinals.
Index: doc/getdate.texi
===================================================================
RCS file: /fetish/cu/doc/getdate.texi,v
retrieving revision 1.24
diff -p -u -r1.24 getdate.texi
--- doc/getdate.texi 29 Oct 2004 23:43:34 -0000 1.24
+++ doc/getdate.texi 16 Nov 2004 04:48:26 -0000
@@ -89,13 +89,17 @@ many flavors of items:
@findex first @r{in date strings}
@findex next @r{in date strings}
@findex last @r{in date strings}
-A few numbers may be written out in words in most contexts. This is
+A few ordinal numbers may be written out in words in some contexts. This is
most useful for specifying day of the week items or relative items (see
-below). Here is the list: @samp{first} for 1, @samp{next} for 2,
address@hidden for 3, @samp{fourth} for 4, @samp{fifth} for 5,
+below). Among the most commonly used ordinal numbers, the word
address@hidden stands for @math{-1}, @samp{this} stands for 0, and
address@hidden and @samp{next} both stand for 1. Because the word
address@hidden stands for the unit of time there is no way to write the
+ordinal number 2, but for convenience @samp{third} stands for 3,
address@hidden for 4, @samp{fifth} for 5,
@samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
@samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
address@hidden for 12. Also, @samp{last} means exactly @math{-1}.
address@hidden for 12.
@cindex months, written-out
When a month is written this way, it is still considered to be written
Index: lib/getdate.y
===================================================================
RCS file: /fetish/cu/lib/getdate.y,v
retrieving revision 1.89
diff -p -u -r1.89 getdate.y
--- lib/getdate.y 11 Nov 2004 06:07:57 -0000 1.89
+++ lib/getdate.y 16 Nov 2004 04:48:26 -0000
@@ -201,7 +201,8 @@ static int yyerror (parser_control *, ch
%token tAGO tDST
%token <intval> tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tLOCAL_ZONE tMERIDIAN
-%token <intval> tMINUTE_UNIT tMONTH tMONTH_UNIT tSEC_UNIT tYEAR_UNIT tZONE
+%token <intval> tMINUTE_UNIT tMONTH tMONTH_UNIT tORDINAL
+%token <intval> tSEC_UNIT tYEAR_UNIT tZONE
%token <textintval> tSNUMBER tUNUMBER
%token <timespec> tSDECIMAL_NUMBER tUDECIMAL_NUMBER
@@ -317,6 +318,11 @@ day:
pc->day_ordinal = 1;
pc->day_number = $1;
}
+ | tORDINAL tDAY
+ {
+ pc->day_ordinal = $1;
+ pc->day_number = $2;
+ }
| tUNUMBER tDAY
{
pc->day_ordinal = $1.value;
@@ -412,36 +418,48 @@ rel:
;
relunit:
- tUNUMBER tYEAR_UNIT
+ tORDINAL tYEAR_UNIT
+ { pc->rel_year += $1 * $2; }
+ | tUNUMBER tYEAR_UNIT
{ pc->rel_year += $1.value * $2; }
| tSNUMBER tYEAR_UNIT
{ pc->rel_year += $1.value * $2; }
| tYEAR_UNIT
{ pc->rel_year += $1; }
+ | tORDINAL tMONTH_UNIT
+ { pc->rel_month += $1 * $2; }
| tUNUMBER tMONTH_UNIT
{ pc->rel_month += $1.value * $2; }
| tSNUMBER tMONTH_UNIT
{ pc->rel_month += $1.value * $2; }
| tMONTH_UNIT
{ pc->rel_month += $1; }
+ | tORDINAL tDAY_UNIT
+ { pc->rel_day += $1 * $2; }
| tUNUMBER tDAY_UNIT
{ pc->rel_day += $1.value * $2; }
| tSNUMBER tDAY_UNIT
{ pc->rel_day += $1.value * $2; }
| tDAY_UNIT
{ pc->rel_day += $1; }
+ | tORDINAL tHOUR_UNIT
+ { pc->rel_hour += $1 * $2; }
| tUNUMBER tHOUR_UNIT
{ pc->rel_hour += $1.value * $2; }
| tSNUMBER tHOUR_UNIT
{ pc->rel_hour += $1.value * $2; }
| tHOUR_UNIT
{ pc->rel_hour += $1; }
+ | tORDINAL tMINUTE_UNIT
+ { pc->rel_minutes += $1 * $2; }
| tUNUMBER tMINUTE_UNIT
{ pc->rel_minutes += $1.value * $2; }
| tSNUMBER tMINUTE_UNIT
{ pc->rel_minutes += $1.value * $2; }
| tMINUTE_UNIT
{ pc->rel_minutes += $1; }
+ | tORDINAL tSEC_UNIT
+ { pc->rel_seconds += $1 * $2; }
| tUNUMBER tSEC_UNIT
{ pc->rel_seconds += $1.value * $2; }
| tSNUMBER tSEC_UNIT
@@ -579,21 +597,21 @@ static table const relative_time_table[]
{ "YESTERDAY",tDAY_UNIT, -1 },
{ "TODAY", tDAY_UNIT, 0 },
{ "NOW", tDAY_UNIT, 0 },
- { "LAST", tUNUMBER, -1 },
- { "THIS", tUNUMBER, 0 },
- { "NEXT", tUNUMBER, 1 },
- { "FIRST", tUNUMBER, 1 },
-/*{ "SECOND", tUNUMBER, 2 }, */
- { "THIRD", tUNUMBER, 3 },
- { "FOURTH", tUNUMBER, 4 },
- { "FIFTH", tUNUMBER, 5 },
- { "SIXTH", tUNUMBER, 6 },
- { "SEVENTH", tUNUMBER, 7 },
- { "EIGHTH", tUNUMBER, 8 },
- { "NINTH", tUNUMBER, 9 },
- { "TENTH", tUNUMBER, 10 },
- { "ELEVENTH", tUNUMBER, 11 },
- { "TWELFTH", tUNUMBER, 12 },
+ { "LAST", tORDINAL, -1 },
+ { "THIS", tORDINAL, 0 },
+ { "NEXT", tORDINAL, 1 },
+ { "FIRST", tORDINAL, 1 },
+/*{ "SECOND", tORDINAL, 2 }, */
+ { "THIRD", tORDINAL, 3 },
+ { "FOURTH", tORDINAL, 4 },
+ { "FIFTH", tORDINAL, 5 },
+ { "SIXTH", tORDINAL, 6 },
+ { "SEVENTH", tORDINAL, 7 },
+ { "EIGHTH", tORDINAL, 8 },
+ { "NINTH", tORDINAL, 9 },
+ { "TENTH", tORDINAL, 10 },
+ { "ELEVENTH", tORDINAL, 11 },
+ { "TWELFTH", tORDINAL, 12 },
{ "AGO", tAGO, 1 },
{ NULL, 0, 0 }
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gnulib] Re: shellutils: date -d 'last june' +'%B %Y' -> May 2004,
Paul Eggert <=