From 5c461fdd41017bc2bae63d35aae8aa33d76a5a45 Mon Sep 17 00:00:00 2001 From: hubertf Date: Fri, 24 Jul 1998 23:18:07 +0000 Subject: Consider leap years, as per PR 5830 by Joseph Myers --- adventure/wizard.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'adventure/wizard.c') diff --git a/adventure/wizard.c b/adventure/wizard.c index ae064219..487bce73 100644 --- a/adventure/wizard.c +++ b/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: wizard.c,v 1.6 1997/10/11 01:53:40 lukem Exp $ */ +/* $NetBSD: wizard.c,v 1.7 1998/07/24 23:18:07 hubertf Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: wizard.c,v 1.6 1997/10/11 01:53:40 lukem Exp $"); +__RCSID("$NetBSD: wizard.c,v 1.7 1998/07/24 23:18:07 hubertf Exp $"); #endif #endif /* not lint */ @@ -66,8 +66,10 @@ datime(d, t) time(&tvec); tptr = localtime(&tvec); /* day since 1977 (mod leap) */ - *d = tptr->tm_yday + 365 * (tptr->tm_year - 77); - /* bug: this will overflow in the year 2066 AD */ + *d = (tptr->tm_yday + 365 * (tptr->tm_year - 77) + + (tptr->tm_year - 77) / 4 - (tptr->tm_year - 1) / 100 + + (tptr->tm_year + 299) / 400); + /* bug: this will overflow in the year 2066 AD (with 16 bit int) */ /* it will be attributed to Wm the C's millenial celebration */ /* and minutes since midnite */ *t = tptr->tm_hour * 60 + tptr->tm_min; -- cgit v1.2.3-56-ge451