summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-12-01 19:15:03 +0000
committerJim Meyering <jim@meyering.net>1996-12-01 19:15:03 +0000
commit809464b39048da6beb7fa2c216ca8667f6799f67 (patch)
tree85da85d6903f8a098c85519b6d719adf974c78e2
parent3b3231a029a148f719f3347a4ec9ab11f7625231 (diff)
downloadgnulib-809464b39048da6beb7fa2c216ca8667f6799f67.tar.gz
(date): Interpret the date, L/M/N, as YYYY/MM/DD
if L >= 1000, otherwise as MM/DD/YY. With this change, date --date=DATE accepts dates like those in an RCS log listing.
-rw-r--r--lib/getdate.y19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/getdate.y b/lib/getdate.y
index 6988604dd8..8e35c9203d 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -312,9 +312,22 @@ date : tUNUMBER '/' tUNUMBER {
yyDay = $3;
}
| tUNUMBER '/' tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- yyYear = $5;
+ /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
+ The goal in recognizing YYYY/MM/DD is solely to support legacy
+ machine-generated dates like those in an RCS log listing. If
+ you want portability, use the ISO 8601 format. */
+ if ($1 >= 1000)
+ {
+ yyYear = $1;
+ yyMonth = $3;
+ yyDay = $5;
+ }
+ else
+ {
+ yyMonth = $1;
+ yyDay = $3;
+ yyYear = $5;
+ }
}
| tUNUMBER tSNUMBER tSNUMBER {
/* ISO 8601 format. yyyy-mm-dd. */