[PATCH 1 of 1] Fix: Timestamp handling in patchbomb not working in windows

Volker Kleinfeld Volker.Kleinfeld at gmx.de
Thu Sep 15 08:16:51 CDT 2005


# HG changeset patch
# User Volker.Kleinfeld at gmx.de
# Node ID d50763296ef066e35ca22f0b886daca1ca183831
# Parent  effff847870f7dd033c61f0f02f60098a2d42f72
Fix: Timestamp handling in patchbomb not working in windows.

Changes in contrib/patchbomb
- The time formatting string in patchbomb is not plattform independent.
- Changed to a plattform independent formatting string and a 
  plattform independent way to calculate the differenence to UTC time.

diff -r effff847870f -r d50763296ef0 contrib/patchbomb
--- a/contrib/patchbomb	Fri Sep 09 19:19:24 2005
+++ b/contrib/patchbomb	Wed Sep 14 08:58:49 2005
@@ -221,7 +221,14 @@
         if username and password:
             s.login(username, password)
     parent = None
-    tz = time.strftime('%z')
+
+    # Calculate UTC offset
+    if time.daylight: offset = time.altzone
+    else: offset = time.timezone
+    if offset <= 0: sign, offset = '+', -offset
+    else: sign = '-'
+    offset = '%s%02d%02d' % (sign, offset / 3600, (offset % 3600) / 60)
+
     for m in msgs:
         try:
             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
@@ -231,7 +238,7 @@
             m['In-Reply-To'] = parent
         else:
             parent = m['Message-Id']
-        m['Date'] = time.strftime('%a, %e %b %Y %T ', time.localtime(start_time)) + tz
+        m['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(start_time)) + ' ' + offset
         start_time += 1
         m['From'] = sender
         m['To'] = ', '.join(to)


More information about the Mercurial mailing list