diff mercurial/debugcommands.py @ 30516:ef1353c283e3

debugcommands: move 'debugdate' in the new module
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 17 Aug 2016 20:43:31 -0700
parents cdd1885d0f2f
children a3ec6db36315
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Aug 17 20:43:05 2016 -0700
+++ b/mercurial/debugcommands.py	Wed Aug 17 20:43:31 2016 -0700
@@ -28,6 +28,7 @@
     scmutil,
     simplemerge,
     streamclone,
+    util,
 )
 
 release = lockmod.release
@@ -434,3 +435,19 @@
         ui.write(r.revision(r.lookup(rev)))
     except KeyError:
         raise error.Abort(_('invalid revision identifier %s') % rev)
+
+@command('debugdate',
+    [('e', 'extended', None, _('try extended date formats'))],
+    _('[-e] DATE [RANGE]'),
+    norepo=True, optionalrepo=True)
+def debugdate(ui, date, range=None, **opts):
+    """parse and display a date"""
+    if opts["extended"]:
+        d = util.parsedate(date, util.extendeddateformats)
+    else:
+        d = util.parsedate(date)
+    ui.write(("internal: %s %s\n") % d)
+    ui.write(("standard: %s\n") % util.datestr(d))
+    if range:
+        m = util.matchdate(range)
+        ui.write(("match: %s\n") % m(d[0]))