ogajduse / rpms / texlive

Forked from rpms/texlive 6 years ago
Clone
4931932
# 61_dvipdfm_timezone by "Mark A. Wicks" <mwicks@kettering.edu>
4931932
#
4931932
# fix crash of dvipdfm with 0.5 timezones
4931932
4931932
 build/source/texk/dvipdfm/pdfdoc.c |   34 +++++++++++++++++++++++-----------
4931932
 1 file changed, 23 insertions(+), 11 deletions(-)
4931932
4931932
Index: texlive-bin-2007/build/source/texk/dvipdfm/pdfdoc.c
4931932
===================================================================
4931932
--- texlive-bin-2007.orig/build/source/texk/dvipdfm/pdfdoc.c	2006-01-17 22:41:51.000000000 +0100
4931932
+++ texlive-bin-2007/build/source/texk/dvipdfm/pdfdoc.c	2007-02-15 15:53:08.000000000 +0100
4931932
@@ -232,13 +232,7 @@
4931932
 
4931932
 static char *asn_date (void)
4931932
 {
4931932
-#ifndef HAVE_TIMEZONE
4931932
-  #ifdef TM_GM_TOFF
4931932
-     #define timezone (bdtime->gm_toff)
4931932
-  #else
4931932
-     #define timezone 0l
4931932
-#endif /* TM_GM_TOFF */
4931932
-#endif /* HAVE_TIMEZONE */
4931932
+  long tz_offset;
4931932
   static char date_string[24];
4931932
   time_t current_time;
4931932
   struct tm *bd_time;
4931932
@@ -247,10 +241,28 @@
4931932
   }
4931932
   time(&current_time);
4931932
   bd_time = localtime(&current_time);
4931932
-  sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%+03ld'%02ld'",
4931932
-	   bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
4931932
-	   bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
4931932
-	   -timezone/3600, timezone%3600);
4931932
+
4931932
+#ifdef HAVE_TM_GMTOFF  /* Preferred way to get time zone offset */
4931932
+  tz_offset = bd_time->tm_gmtoff;
4931932
+#else
4931932
+#ifdef HAVE_TIMEZONE   /* Plan B --- use external variable 'timezone'
4931932
+                       /* (may not provide correct offset for daylight savings time) */
4931932
+  tz_offset = - timezone;
4931932
+#else                  /* Last resort --- without more information, set offset to zero */
4931932
+  tz_offset = 0l;
4931932
+#endif /* HAVE_TIMEZONE */
4931932
+#endif /* HAVE_TM_GMTOFF */
4931932
+
4931932
+  if (tz_offset == 0l) {
4931932
+    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02dZ00'00'",
4931932
+	     bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
4931932
+	     bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec);
4931932
+  } else {
4931932
+    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%c%02ld'%02ld'",
4931932
+             bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
4931932
+             bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
4931932
+	     (tz_offset>0)? '+':'-', labs(tz_offset)/3600, (labs(tz_offset)/60)%60);
4931932
+  }
4931932
   return date_string;
4931932
 }
4931932