octave-maintainers
[Top][All Lists]
Advanced

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

MSVC patch: strptime and year < 1970


From: John W. Eaton
Subject: MSVC patch: strptime and year < 1970
Date: Wed, 6 Dec 2006 14:31:12 -0500

On  6-Dec-2006, address@hidden wrote:

| The attached patch solves a problem in weekday computation for time
| before January 1st 1970. The computed weekday was negative.

 Index: liboctave/strptime.c
===================================================================
RCS file: /cvs/octave/liboctave/strptime.c,v
retrieving revision 1.5
diff -c -p -r1.5 strptime.c
*** liboctave/strptime.c        26 Apr 2005 19:24:29 -0000      1.5
--- liboctave/strptime.c        6 Dec 2006 10:17:03 -0000
*************** day_of_the_week (struct tm *tm)
*** 240,245 ****
--- 240,248 ----
              + __mon_yday[0][tm->tm_mon]
              + tm->tm_mday - 1);
    tm->tm_wday = wday % 7;
+   /* Handle cases before January 1st 1970 */
+   if (tm->tm_wday < 0)
+     tm->tm_wday += 7;
  }
  
  /* Compute the day of the year.  */


The current glibc code uses

  tm->tm_wday = ((wday % 7) + 7) % 7;

Does that work for you?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]