[issue272] Timestamp handling in patchbomb/email extensio not working in windows.

Volker Kleinfeld mercurial-bugs at selenic.com
Mon May 29 02:39:24 CDT 2006


New submission from Volker Kleinfeld <Volker.Kleinfeld at gmx.de>:

The email time stamp is not handled in a plattform independent way. The
attached fix was discussed long time ago but no bug was ever filed.

----------
files: email_time.patch
messages: 1423
nosy: bos, vok
priority: bug
status: unread
title: Timestamp handling in patchbomb/email extensio not working in windows.
topic: windows

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue272>
____________________________________________________
-------------- next part --------------
# HG changeset patch
# User Volker Kleinfeld <Volker.Kleinfeld at gmx.de>
# Node ID ef2654e3eed72bec3df29cadda6eb642e976d1b6
# Parent  4be9a79b49b177f5c44c4f32b22999ff5583880a
patchbomb does not handle email time stamp plattform independent

diff -r 4be9a79b49b1 -r ef2654e3eed7 hgext/patchbomb.py
--- a/hgext/patchbomb.py	Wed May 17 13:21:36 2006 -0500
+++ b/hgext/patchbomb.py	Mon May 22 18:37:36 2006 +0200
@@ -217,7 +217,14 @@ def patchbomb(ui, repo, *revs, **opts):
     if not opts['test'] and not opts['mbox']:
         mail = ui.sendmail()
     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)
+
     sender_addr = email.Utils.parseaddr(sender)[1]
     for m in msgs:
         try:
@@ -228,7 +235,8 @@ def patchbomb(ui, repo, *revs, **opts):
             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