diff options
author | alex <alex@FreeBSD.org> | 1998-01-08 02:21:30 +0000 |
---|---|---|
committer | alex <alex@FreeBSD.org> | 1998-01-08 02:21:30 +0000 |
commit | 52c4bf5ce3912c22aaf261f60278883b73c7243b (patch) | |
tree | 8cc1bb18a0525d90b8829e6c2677f38b8789fb35 /sbin/shutdown | |
parent | 6734c6448e85c13b81bb87a6069a04da403892ff (diff) | |
download | FreeBSD-src-52c4bf5ce3912c22aaf261f60278883b73c7243b.zip FreeBSD-src-52c4bf5ce3912c22aaf261f60278883b73c7243b.tar.gz |
Allow 'shutdown datespec' to work into the next century. Handle dates
in the 22nd century and beyond even though it's irrelevant with a 32-bit
time_t which expires in the year 2038.
Diffstat (limited to 'sbin/shutdown')
-rw-r--r-- | sbin/shutdown/shutdown.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c index d9fc5da..8c3b01e 100644 --- a/sbin/shutdown/shutdown.c +++ b/sbin/shutdown/shutdown.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: shutdown.c,v 1.7 1997/06/19 14:28:32 charnier Exp $ + * $Id: shutdown.c,v 1.8 1997/08/23 14:10:34 joerg Exp $ */ #ifndef lint @@ -350,6 +350,7 @@ getoffset(timearg) register struct tm *lt; register char *p; time_t now; + int this_year; if (!strcasecmp(timearg, "now")) { /* now */ offset = 0; @@ -381,7 +382,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 centuries beyond 2000 */ + lt->tm_year += (this_year - (this_year % 100)); /* FALLTHROUGH */ case 8: lt->tm_mon = ATOI2(timearg); |