[S 21.5] Fix signs in time zone string.

Marcus Crestani <[email protected]> Thu, 02 Oct 2014 08:12:09 +0200
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
SUPERSEDES PATCH 21.5

>>>>>"SJT" == Stephen J Turnbull <[email protected]> writes:
SJT> "+0" is prettier, but there may be code that looks for "-0" explicitly
SJT> out there (eg, to test for GMT).  If you're going to do it differently
SJT> from GNU, please document it.

Sure, see below.  Is the comment clear enough?  Should it mention that
GNU Emacs does it differently?

diff --git a/src/editfns.c b/src/editfns.c
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1190,9 +1190,13 @@
       else if (FIXNUMP (zone))
 	{
 	  int abszone = abs (XFIXNUM (zone));
-	  /* #### I have no idea what this conforms to,
-	     but the compiler has stopped whining. */
-	  sprintf (tzbuf, "XXX%s%d:%02d:%02d", (XFIXNUM (zone) < 0) ? "-" : "+",
+	  /* We specify the time zone in offset notation (see `man
+	     tzset' for details).  The offset indicates the value one
+	     must add to local time to arrive at UTC.  Thus, we sign
+	     the offset with a `-' if the time zone is east of GMT; we
+	     sign the offset with a `+' if the time zone is GMT (then
+	     the offset is 0) or if the time zone is west of GMT. */
+	  sprintf (tzbuf, "XXX%s%d:%02d:%02d", (XFIXNUM (zone) < 0) ? "+" : "-",
 		   abszone / (60*60), (abszone/60) % 60, abszone % 60);
 	  tzstring = tzbuf;
 	}

-- 
Marcus