(0.9.2compat) prefer util.datestr over time module import 0.9.2compat
authorChristian Ebert <blacktrash@gmx.net>
Wed, 05 Aug 2009 17:18:32 +0200
branch0.9.2compat
changeset 639 d41074cb161b
parent 638 439e096ce144
child 640 7e80fc29ba27
(0.9.2compat) prefer util.datestr over time module import We keep the function in this branch to catch the TypeError.
hgkw/keyword.py
--- a/hgkw/keyword.py	Wed Aug 05 17:01:55 2009 +0200
+++ b/hgkw/keyword.py	Wed Aug 05 17:18:32 2009 +0200
@@ -90,7 +90,7 @@
 from mercurial import localrepo, patch, revlog, templater, util
 from mercurial.node import nullid, hex
 from mercurial.i18n import gettext as _
-import getopt, os, re, shutil, tempfile, time
+import getopt, os, re, shutil, tempfile
 
 commands.optionalrepo += ' kwdemo'
 
@@ -103,9 +103,12 @@
 # not when reading filelog, and unexpand when reading from working dir
 restricted = 'merge record resolve qfold qimport qnew qpush qrefresh qrecord'
 
+# provide cvs-like UTC date filter
 def utcdate(date):
-    '''Returns hgdate in cvs-like UTC format.'''
-    return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
+    try:
+        return util.datestr(date, '%Y/%m/%d %H:%M:%S', False)
+    except TypeError:
+        return util.datestr(date, '%Y/%m/%d %H:%M:%S')
 
 def textsafe(s):
     '''Safe version of util.binary with reversed logic.