This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to initialize time zone for strftime


I may have posted a patch like this a few months ago, but it hasn't
shown up in the sources, so I assume it was mislaid.

The bug that this fixes is this:

    (strftime "%c %Z" (localtime (current-time)))

returns something like

    "Fri Feb 12 08:19:35 1999 xxgarbagexx"

whereas it should return something like

    "Fri Feb 12 08:19:35 1999 PST"

I made this diff by hand, so it's possible that `patch' will puke on
it.  No problem; just edit the function `bdtime2c'; it'll be obvious
how to apply this.

--- stime.c	1999/02/06 12:30:54	1.30
+++ stime.c	1999/02/12 15:52:50

 	      && SCM_INUMP (SCM_VELTS (sbd_time)[5])
 	      && SCM_INUMP (SCM_VELTS (sbd_time)[6])
 	      && SCM_INUMP (SCM_VELTS (sbd_time)[7])
-	      && SCM_INUMP (SCM_VELTS (sbd_time)[8]),
+	      && SCM_INUMP (SCM_VELTS (sbd_time)[8])
+	      && SCM_STRINGP (SCM_VELTS (sbd_time)[10]),
 	      sbd_time, pos, subr);
   lt->tm_sec = SCM_INUM (SCM_VELTS (sbd_time)[0]);
   lt->tm_min = SCM_INUM (SCM_VELTS (sbd_time)[1]);

   lt->tm_wday = SCM_INUM (SCM_VELTS (sbd_time)[6]);
   lt->tm_yday = SCM_INUM (SCM_VELTS (sbd_time)[7]);
   lt->tm_isdst = SCM_INUM (SCM_VELTS (sbd_time)[8]);
+#ifdef HAVE_TM_ZONE
+  lt->tm_gmtoff = SCM_INUM (SCM_VELTS (sbd_time)[9]);
+  lt->tm_zone  = SCM_CHARS (SCM_VELTS (sbd_time)[10]);
+#endif
 }
 
 SCM_PROC (s_mktime, "mktime", 1, 1, 0, scm_mktime);