Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: "strftime -r" messes up with DST on Solaris



This:

  zmodload -i zsh/datetime
  strftime -r "%Y %b %d %H %M %S" "2007 April 12 15 18 00"'

gives the wrong answer on Solaris because strptime() zeroes the
tm_isdst element that we carefully set to -1 to indicate we didn't
know it.  There's no way of telling the resulting zero apart from
a value set explicitly from the input format, so mktime() thinks that
it's not summer time, whereas is is (it's even quite warm out).
Luckily, there's a "make it work" definition you can set.

Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.41
diff -u -r1.41 system.h
--- Src/system.h	5 Jun 2006 16:55:38 -0000	1.41
+++ Src/system.h	12 Apr 2007 15:20:40 -0000
@@ -52,6 +52,17 @@
 # undef HAVE_SYS_UTSNAME_H
 #endif
 
+/*
+ * Solaris by default zeroes all elements of the tm structure in
+ * strptime().  Unfortunately that gives us no way of telling whether
+ * the tm_isdst element has been set from the input pattern.  If it
+ * hasn't we want it to be -1 (undetermined) on input to mktime().  So
+ * we stop strptime() being zeroed and set all the elements ourselves.
+ *
+ * This is likely to be harmless everywhere else.
+ */
+#define _STRPTIME_DONTZERO
+
 #ifdef PROTOTYPES
 # define _(Args) Args
 #else

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



Messages sorted by: Reverse Date, Date, Thread, Author