summaryrefslogtreecommitdiff
path: root/bin/date
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-06-23 19:34:58 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-06-23 19:34:58 +0000
commitf25b15f6fa982b145696b8eaec5d095ae1bfe65c (patch)
treeb3b66cdb3f24bf1ad73b9dccd24286fbd7028cd2 /bin/date
parenta5b0c83fb53183d517e806c2e4c87c04b656a44d (diff)
yyyy specification code; m4@nts.umn.edu
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/date.17
-rw-r--r--bin/date/date.c15
2 files changed, 17 insertions, 5 deletions
diff --git a/bin/date/date.1 b/bin/date/date.1
index 3ae6fb6bf25..e2fd00b64bd 100644
--- a/bin/date/date.1
+++ b/bin/date/date.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: date.1,v 1.5 1997/05/30 09:12:50 deraadt Exp $
+.\" $OpenBSD: date.1,v 1.6 1997/06/23 19:34:55 deraadt Exp $
.\" $NetBSD: date.1,v 1.12 1996/03/12 04:32:37 phil Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@@ -50,7 +50,7 @@
.Op Fl t Ar minutes_west
.Op Fl nu
.Op Cm + Ns Ar format
-.Op [yy[mm[dd[hh]]]]mm[\&.ss]
+.Op [[yy]yy[mm[dd[hh]]]]mm[\&.ss]
.Sh DESCRIPTION
.Nm Date
displays the current date and time when invoked without arguments.
@@ -121,6 +121,9 @@ The canonical representation for setting the date and time is:
.Bl -tag -width Ds -compact -offset indent
.It Ar yy
Year in abbreviated form (.e.g 89 for 1989, 06 for 2006).
+The format
+.Ar yyyymmddhhmm
+is also permitted, for non-ambiguous years beyond 1999.
.It Ar mm
Numeric month.
A number from 1 to 12.
diff --git a/bin/date/date.c b/bin/date/date.c
index 3a2082535d6..763a6f0c481 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: date.c,v 1.4 1997/04/16 20:58:09 deraadt Exp $ */
+/* $OpenBSD: date.c,v 1.5 1997/06/23 19:34:57 deraadt Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: date.c,v 1.4 1997/04/16 20:58:09 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: date.c,v 1.5 1997/06/23 19:34:57 deraadt Exp $";
#endif
#endif /* not lint */
@@ -178,10 +178,19 @@ setthetime(p)
lt->tm_sec = 0;
switch (strlen(p)) {
+ case 12: /* yyyy */
+ bigyear = ATOI2(p);
+ bigyear = bigyear * 100 - 1900;
+ /* FALLTHROUGH */
case 10: /* yy */
- lt->tm_year = ATOI2(p);
+ lt->tm_year = bigyear;
+ lt->tm_year += ATOI2(p);
if (lt->tm_year < 69) /* hack for 2000 ;-} */
lt->tm_year += 100;
+ if (lt->tm_year > (2037-1900)) {
+ warnx("year too large (overflows 32 bit value)");
+ exit(1);
+ }
/* FALLTHROUGH */
case 8: /* mm */
lt->tm_mon = ATOI2(p);