summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAlex Feldman <alex@cvs.openbsd.org>1999-04-29 22:25:05 +0000
committerAlex Feldman <alex@cvs.openbsd.org>1999-04-29 22:25:05 +0000
commitd8fdfa5c3dd1aecb5a53cab412e78ab3b5c9833c (patch)
treed6e74a0042c966303f21907c1cb5706f4525f91a /sbin
parent55f2df96942e22e55589ed9df34cbdfb75cfd2d5 (diff)
Y2K fix: allow 'shutdown yymmddhhmm' to work in the next century.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/shutdown/shutdown.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 217d757577a..63d2a8f1d84 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shutdown.c,v 1.14 1998/04/25 04:45:38 millert Exp $ */
+/* $OpenBSD: shutdown.c,v 1.15 1999/04/29 22:25:04 alex Exp $ */
/* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
#else
-static char rcsid[] = "$OpenBSD: shutdown.c,v 1.14 1998/04/25 04:45:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: shutdown.c,v 1.15 1999/04/29 22:25:04 alex Exp $";
#endif
#endif /* not lint */
@@ -422,6 +422,7 @@ getoffset(timearg)
register struct tm *lt;
register char *p;
time_t now;
+ int this_year;
if (!strcasecmp(timearg, "now")) { /* now */
offset = 0;
@@ -453,7 +454,17 @@ getoffset(timearg)
switch(strlen(timearg)) {
case 10:
+ this_year = lt->tm_year;
lt->tm_year = ATOI2(timearg);
+ /*
+ * check if the specified year is in the next century.
+ * allow for one year of user error as many people will
+ * enter n - 1 at the start of year n.
+ */
+ if (lt->tm_year < (this_year % 100) - 1)
+ lt->tm_year += 100;
+ /* adjust for the year 2000 and beyond */
+ lt->tm_year += (this_year - (this_year % 100));
/* FALLTHROUGH */
case 8:
lt->tm_mon = ATOI2(timearg);