From 6269e521192ef37e1b13183baf44a05e16695e6d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 14 Dec 1998 21:27:19 +0000 Subject: 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 --- time/strptime.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'time/strptime.c') 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 * -- cgit v1.2.3