Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/vax Correct definition of leap year. Make yeartonu...



details:   https://anonhg.NetBSD.org/src/rev/8ad9278a6358
branches:  trunk
changeset: 758871:8ad9278a6358
user:      uwe <uwe%NetBSD.org@localhost>
date:      Fri Nov 19 03:31:24 2010 +0000

description:
Correct definition of leap year.  Make yeartonum and numtoyear use
full years so that year 2000 is correctly counted as a leap year.

Now NetBSD under SIMH picks up correct time-of-day clock value.  It
used to be a day behind, since 2000 - 1900 = 100 and naive leap year
test wouldn't count it as a leap year.

diffstat:

 sys/arch/vax/include/clock.h |   4 ++--
 sys/arch/vax/vax/clock.c     |  10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r 728ec0d2a23f -r 8ad9278a6358 sys/arch/vax/include/clock.h
--- a/sys/arch/vax/include/clock.h      Fri Nov 19 00:44:18 2010 +0000
+++ b/sys/arch/vax/include/clock.h      Fri Nov 19 03:31:24 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.h,v 1.7 2009/12/12 14:44:09 tsutsui Exp $ */
+/*     $NetBSD: clock.h,v 1.8 2010/11/19 03:31:24 uwe Exp $ */
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -37,7 +37,7 @@
 /*
  * Time constants. These are unlikely to change.
  */
-#define IS_LEAPYEAR(y) (((y % 4) == 0) && (y % 100))
+#define IS_LEAPYEAR(y) ((((y % 4) == 0) && ((y % 100) != 0)) || ((y % 400) == 0))
 
 #define SEC_PER_MIN    (60)
 #define SEC_PER_HOUR   (SEC_PER_MIN * 60)
diff -r 728ec0d2a23f -r 8ad9278a6358 sys/arch/vax/vax/clock.c
--- a/sys/arch/vax/vax/clock.c  Fri Nov 19 00:44:18 2010 +0000
+++ b/sys/arch/vax/vax/clock.c  Fri Nov 19 03:31:24 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.53 2010/07/01 19:50:12 ragge Exp $  */
+/*     $NetBSD: clock.c,v 1.54 2010/11/19 03:31:24 uwe Exp $    */
 /*
  * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.53 2010/07/01 19:50:12 ragge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.54 2010/11/19 03:31:24 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -199,18 +199,18 @@
 {
        int n;
 
-       for (n = 0, y -= 1; y > 69; y--)
+       for (n = 0, y -= 1; y > 1969; y--)
                n += SECPERYEAR(y);
        return n;
 }
 
 /* 
- * Converts tick number to a year 70 ->
+ * Converts tick number to a year 1970 ->
  */
 int
 numtoyear(int num)
 {
-       int y = 70, j;
+       int y = 1970, j;
        while(num >= (j = SECPERYEAR(y))) {
                y++;
                num -= j;



Home | Main Index | Thread Index | Old Index