texlive[68952] Build/source/texk/dvipdfm-x: calculate time zone

commits+kakuto at tug.org commits+kakuto at tug.org
Fri Nov 24 03:47:51 CET 2023


Revision: 68952
          https://tug.org/svn/texlive?view=revision&revision=68952
Author:   kakuto
Date:     2023-11-24 03:47:51 +0100 (Fri, 24 Nov 2023)
Log Message:
-----------
calculate time zone offset in the same way as in pdftex

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/configure
    trunk/Build/source/texk/dvipdfm-x/configure.ac
    trunk/Build/source/texk/dvipdfm-x/dpxutil.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2023-11-24 00:41:25 UTC (rev 68951)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2023-11-24 02:47:51 UTC (rev 68952)
@@ -1,3 +1,8 @@
+2023-11-24  Akira Kakuto  <kakuto at jcom.zaq.ne.jp>
+	* dpxutil.c: Calculate time zone offset in the same way as
+	in pdftex.
+	* configure.ac: version 20231124.
+
 2023-11-18  Yukimasa Morimi  <h20y6m at yahoo.co.jp>
 
 	* cidtype2.c, unicode.c: Support for new Adobe-Japan1-UCS2 CMap.

Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure	2023-11-24 00:41:25 UTC (rev 68951)
+++ trunk/Build/source/texk/dvipdfm-x/configure	2023-11-24 02:47:51 UTC (rev 68952)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for dvipdfm-x (TeX Live) 20231118.
+# Generated by GNU Autoconf 2.71 for dvipdfm-x (TeX Live) 20231124.
 #
 # Report bugs to <dvipdfmx at tug.org>.
 #
@@ -629,8 +629,8 @@
 # Identity of this package.
 PACKAGE_NAME='dvipdfm-x (TeX Live)'
 PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20231118'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20231118'
+PACKAGE_VERSION='20231124'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20231124'
 PACKAGE_BUGREPORT='dvipdfmx at tug.org'
 PACKAGE_URL=''
 
@@ -1396,7 +1396,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20231118 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20231124 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1468,7 +1468,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20231118:";;
+     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20231124:";;
    esac
   cat <<\_ACEOF
 
@@ -1598,7 +1598,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20231118
+dvipdfm-x (TeX Live) configure 20231124
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2354,7 +2354,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dvipdfm-x (TeX Live) $as_me 20231118, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20231124, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -8795,7 +8795,7 @@
 
 # Define the identity of the package.
  PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20231118'
+ VERSION='20231124'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -15801,7 +15801,7 @@
 Report bugs to <bug-libtool at gnu.org>."
 
 lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20231118
+dvipdfm-x (TeX Live) config.lt 20231124
 configured by $0, generated by GNU Autoconf 2.71.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -17723,7 +17723,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20231118, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20231124, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -17795,7 +17795,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20231118
+dvipdfm-x (TeX Live) config.status 20231124
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac	2023-11-24 00:41:25 UTC (rev 68951)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac	2023-11-24 02:47:51 UTC (rev 68952)
@@ -8,7 +8,7 @@
 dnl   gives unlimited permission to copy and/or distribute it,
 dnl   with or without modifications, as long as this notice is preserved.
 dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20231118], [dvipdfmx at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20231124], [dvipdfmx at tug.org])
 AC_PREREQ([2.65])
 AC_CONFIG_SRCDIR([agl.c])
 AC_CONFIG_AUX_DIR([../../build-aux])

Modified: trunk/Build/source/texk/dvipdfm-x/dpxutil.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/dpxutil.c	2023-11-24 00:41:25 UTC (rev 68951)
+++ trunk/Build/source/texk/dvipdfm-x/dpxutil.c	2023-11-24 02:47:51 UTC (rev 68952)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2023 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
 
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -190,80 +190,66 @@
   return ret;
 }
 
-
-#ifndef HAVE_TM_GMTOFF
-#ifndef HAVE_TIMEZONE
-
-/* auxiliary function to compute timezone offset on
-   systems that do not support the tm_gmtoff in struct tm,
-   or have a timezone variable.  Such as i386-solaris.  */
-
-static int32_t
-compute_timezone_offset()
-{
-  time_t now;
-  struct tm tm;
-  struct tm local;
-  time_t gmtoff;
-
-  now = get_unique_time_if_given();
-  if (now == INVALID_EPOCH_VALUE) {
-    now = time(NULL);
-    localtime_r(&now, &local);
-    gmtime_r(&now, &tm);
-    return (mktime(&local) - mktime(&tm));
-  } else {
-    return(0);
-  }
-}
-
-#endif /* HAVE_TIMEZONE */
-#endif /* HAVE_TM_GMTOFF */
-
 /*
  * Docinfo
  */
+#define TIME_STR_SIZE 30
 int
 dpx_util_format_asn_date (char *date_string, int need_timezone)
 {
-  int32_t     tz_offset;
+  int32_t     off, off_hours, off_mins;
   time_t      current_time;
-  struct tm  *bd_time;
+  struct tm   bd_time, gmt;
+  size_t      size;
 
   current_time = dpx_util_get_unique_time_if_given();
   if (current_time == INVALID_EPOCH_VALUE) {
     time(&current_time);
-    bd_time = localtime(&current_time);
-
-#ifdef HAVE_TM_GMTOFF
-    tz_offset = bd_time->tm_gmtoff;
-#else
-#  ifdef HAVE_TIMEZONE
-    tz_offset = -timezone;
-#  else
-    tz_offset = compute_timezone_offset();
-#  endif /* HAVE_TIMEZONE */
-#endif /* HAVE_TM_GMTOFF */
+    bd_time = *localtime(&current_time);
   } else {
-    bd_time = gmtime(&current_time);
-    tz_offset = 0;
+    bd_time = *gmtime(&current_time);
   }
+
+  size = strftime(date_string, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", &bd_time);
+  /* expected format: "YYYYmmddHHMMSS" */
+  if (size == 0) {
+    /* unexpected, contents of date_string is undefined */
+    date_string[0] = '\0';
+    return 0;
+  }
+
+  /* correction for seconds: %S can be in range 00..61,
+     the PDF reference expects 00..59,
+     therefore we map "60" and "61" to "59" */
+  if (date_string[14] == '6') {
+    date_string[14] = '5';
+    date_string[15] = '9';
+    date_string[16] = '\0';    /* for safety */
+  }
+
+/* calculate the time zone offset in the same way as in texmfmp.c */
+  gmt = *gmtime(&current_time);
+  off = 60 * (bd_time.tm_hour - gmt.tm_hour) + bd_time.tm_min - gmt.tm_min;
+  if (bd_time.tm_year != gmt.tm_year) {
+    off += (bd_time.tm_year > gmt.tm_year) ? 1440 : -1440;
+  } else if (bd_time.tm_yday != gmt.tm_yday) {
+    off += (bd_time.tm_yday > gmt.tm_yday) ? 1440 : -1440;
+  }
+
   if (need_timezone) {
-    if (bd_time->tm_isdst > 0) {
-      tz_offset += 3600;
+    if (off == 0) {
+      date_string[size++] = 'Z';
+      date_string[size] = 0;
+    } else {
+      off_hours = off / 60;
+      off_mins = abs(off - off_hours * 60);
+      sprintf(&date_string[size], "%+03d'%02d'", off_hours, off_mins);
     }
-    sprintf(date_string, "D:%04d%02d%02d%02d%02d%02d%c%02d'%02d'",
-            bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday,
-            bd_time->tm_hour, bd_time->tm_min, bd_time->tm_sec,
-            (tz_offset > 0) ? '+' : '-', abs(tz_offset) / 3600,
-                                        (abs(tz_offset) / 60) % 60);
   } else {
-    sprintf(date_string, "D:%04d%02d%02d%02d%02d%02d",
-            bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday,
-            bd_time->tm_hour, bd_time->tm_min, bd_time->tm_sec);
+    date_string[size] = 0;
   }
 
-  return strlen(date_string);
+  return (int)strlen(date_string);
 }
 
 void



More information about the tex-live-commits mailing list.