about summary refs log tree commit diff
path: root/time/strptime.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-12-14 21:27:19 +0000
committerUlrich Drepper <drepper@redhat.com>1998-12-14 21:27:19 +0000
commit6269e521192ef37e1b13183baf44a05e16695e6d (patch)
tree1aae4386b3afe689fa982557ff3d61d9f9e73ad9 /time/strptime.c
parentc2cfb5126b85ba4f0b6ec66567616ad221ea9429 (diff)
downloadglibc-6269e521192ef37e1b13183baf44a05e16695e6d.tar.gz
glibc-6269e521192ef37e1b13183baf44a05e16695e6d.tar.xz
glibc-6269e521192ef37e1b13183baf44a05e16695e6d.zip
Update.
	* time/Makefile (tests): Add tst-strptime.
	* time/tst-strptime.c: New file.
	* time/strptime.c: Correct bugs in weekday and yearday computation.

1998-12-14  Ulrich Drepper  <drepper@cygnus.com>
Diffstat (limited to 'time/strptime.c')
-rw-r--r--time/strptime.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/time/strptime.c b/time/strptime.c
index d85dbfac2b..315af83980 100644
--- a/time/strptime.c
+++ b/time/strptime.c
@@ -206,21 +206,23 @@ day_of_the_week (struct tm *tm)
   /* We know that January 1st 1970 was a Thursday (= 4).  Compute the
      the difference between this data in the one on TM and so determine
      the weekday.  */
-  int corr_year = tm->tm_mon >= 2 ? tm->tm_year : tm->tm_year - 1;
+  int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2);
   int wday = (-473
-	      + (365 * (tm->tm_year - 1970))
+	      + (365 * (tm->tm_year - 70))
 	      + (corr_year / 4)
 	      - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)
 	      + (((corr_year / 4) / 25) / 4)
 	      + __mon_yday[0][tm->tm_mon]
-	      + tm->tm_mday);
-  tm->tm_wday = wday;
+	      + tm->tm_mday - 1);
+  tm->tm_wday = wday % 7;
 }
 
+/* Compute the day of the year.  */
 static void
 day_of_the_year (struct tm *tm)
 {
-  tm->tm_yday = __mon_yday[__isleap (tm->tm_year)][tm->tm_mon] + tm->tm_mday;
+  tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon]
+		 + (tm->tm_mday - 1));
 }
 
 static char *