Package: asciidoc
Version: 8.6.9-3
Followup-For: Bug #782294
Tags: patch
User: [email protected]
Usertags: timestamps

User elextr from github noted that function tzset() from the previous patch
only works for unixes:
https://github.com/jumapico/asciidoc/commit/74a0530e0eada1eef853ee0939ba7f9f59b22470
I rewrite the previous patch.

-- System Information:
Debian Release: 8.0
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Description: Add --use-utc-timezone flag for reproducible builds.
 Adds a new flag, --use-utc-timezone, that uses the UTC timezone instead of
 the local one, making the generation of the documentation reproducible.
Author: Juan Picca <[email protected]>
Bug: https://bugs.debian.org/782294
Last-Update: 2014-04-13
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/asciidoc.py
+++ b/asciidoc.py
@@ -1270,9 +1270,11 @@ def char_encode(s):

 def time_str(t):
     """Convert seconds since the Epoch to formatted local time string."""
-    t = time.localtime(t)
+    t = time.localtime(t) if not utc_mode else time.gmtime(t)
     s = time.strftime('%H:%M:%S',t)
-    if time.daylight and t.tm_isdst == 1:
+    if utc_mode:
+        result = s + ' UTC'
+    elif time.daylight and t.tm_isdst == 1:
         result = s + ' ' + time.tzname[1]
     else:
         result = s + ' ' + time.tzname[0]
@@ -1285,7 +1287,7 @@ def time_str(t):

 def date_str(t):
     """Convert seconds since the Epoch to formatted local date string."""
-    t = time.localtime(t)
+    t = time.localtime(t) if not utc_mode else time.gmtime(t)
     return time.strftime('%Y-%m-%d',t)


@@ -5883,6 +5885,7 @@ tables = Tables()           # Table defi
 macros = Macros()           # Macro definitions.
 calloutmap = CalloutMap()   # Coordinates callouts and callout list.
 trace = Trace()             # Implements trace attribute processing.
+utc_mode = False            # Use utc time functions.

 ### Used by asciidocapi.py ###
 # List of message strings written to stderr.
@@ -6219,7 +6222,7 @@ if __name__ == '__main__':
             ['attribute=','backend=','conf-file=','doctype=','dump-conf',
             'help','no-conf','no-header-footer','out-file=',
             'section-numbers','verbose','version','safe','unsafe',
-            'doctest','filter=','theme='])
+            'doctest','use-utc-timezone','filter=','theme='])
     except getopt.GetoptError:
         message.stderr('illegal command options')
         sys.exit(1)
@@ -6234,6 +6237,9 @@ if __name__ == '__main__':
             sys.exit(0)
         else:
             sys.exit(1)
+    # Use UTC timezone for date and time
+    if '--use-utc-timezone' in opt_names:
+        utc_mode = True
     # Look for plugin management commands.
     count = 0
     for o,v in opts:
--- a/doc/asciidoc.1.txt
+++ b/doc/asciidoc.1.txt
@@ -95,6 +95,10 @@ OPTIONS
     The *--theme* option is also used to manage theme plugins (see
     <<X1,*PLUGIN COMMANDS*>>).

+*--use-utc-timezone*::
+    Use the UTC timezone for show dates and times. Afects docdate,
+    doctime, localdate and localtime attributes.
+
 *-v, --verbose*::
     Verbosely print processing information and configuration file
     checks to stderr.

Reply via email to