Since we're poking at shutdown, I think it should parse years with a
century so that conscientious sysadmins can specify unambiguous dates.

Note that specifying dates past 2038 doesn't work (with or without this
diff) because the sleep code is not y2k38 safe.

Index: shutdown.8
===================================================================
RCS file: /cvs/src/sbin/shutdown/shutdown.8,v
retrieving revision 1.39
diff -u -p -r1.39 shutdown.8
--- shutdown.8  19 Nov 2007 08:51:49 -0000      1.39
+++ shutdown.8  20 Jan 2015 21:55:52 -0000
@@ -122,7 +122,7 @@ may be the word
 specify a future time in one of two formats:
 .Ar +number ,
 or
-.Ar yymmddhhmm ,
+.Ar ccyymmddhhmm ,
 where the year, month, and day may be defaulted
 to the current system values.
 The first form brings the system down in
Index: shutdown.c
===================================================================
RCS file: /cvs/src/sbin/shutdown/shutdown.c,v
retrieving revision 1.38
diff -u -p -r1.38 shutdown.c
--- shutdown.c  16 Jan 2015 06:40:01 -0000      1.38
+++ shutdown.c  20 Jan 2015 21:54:41 -0000
@@ -449,6 +449,12 @@ getoffset(char *timearg)
        lt = localtime(&now);                           /* current time val */
 
        switch (strlen(timearg)) {
+       case 12:
+               lt->tm_year = ATOI2(timearg);
+               lt->tm_year *= 100;
+               lt->tm_year += ATOI2(timearg);
+               lt->tm_year -= 1900;
+               goto readmonth;
        case 10:
                this_year = lt->tm_year;
                lt->tm_year = ATOI2(timearg);
@@ -463,6 +469,7 @@ getoffset(char *timearg)
                lt->tm_year += (this_year - (this_year % 100));
                /* FALLTHROUGH */
        case 8:
+readmonth:
                lt->tm_mon = ATOI2(timearg);
                if (--lt->tm_mon < 0 || lt->tm_mon > 11)
                        badtime();

Reply via email to