summaryrefslogtreecommitdiffstats
path: root/adventure
diff options
context:
space:
mode:
authorhubertf <hubertf@NetBSD.org>1998-07-24 23:18:07 +0000
committerhubertf <hubertf@NetBSD.org>1998-07-24 23:18:07 +0000
commit5c461fdd41017bc2bae63d35aae8aa33d76a5a45 (patch)
treec7440574684ee003bda7891d7ab403674c906ab0 /adventure
parent5dd25991e0b709cc15ef3ebfb85498571ceded3f (diff)
downloadbsdgames-darwin-5c461fdd41017bc2bae63d35aae8aa33d76a5a45.tar.gz
bsdgames-darwin-5c461fdd41017bc2bae63d35aae8aa33d76a5a45.tar.zst
bsdgames-darwin-5c461fdd41017bc2bae63d35aae8aa33d76a5a45.zip
Consider leap years, as per PR 5830 by Joseph Myers <jsm28@cam.ac.uk>
Diffstat (limited to 'adventure')
-rw-r--r--adventure/wizard.c10
1 files changed, 6 insertions, 4 deletions
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;