[PATCH V2] util: add doctest to datestr()

Adrian Buehlmann adrian at cadifra.com
Mon Apr 11 17:54:55 UTC 2016


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1460396810 -7200
# Node ID 9e883d780661cf2ef47ca9ade115fd94f287be5b
# Parent  3819c349b1947964573e014a36c00801356d4123
util: add doctest to datestr()

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1583,7 +1583,19 @@
 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'):
     """represent a (unixtime, offset) tuple as a localized time.
     unixtime is seconds since the epoch, and offset is the time zone's
-    number of seconds away from UTC."""
+    number of seconds away from UTC.
+
+    >>> datestr((0, 0))
+    'Thu Jan 01 00:00:00 1970 +0000'
+    >>> datestr((42, 0))
+    'Thu Jan 01 00:00:42 1970 +0000'
+    >>> datestr((-42, 0))
+    'Wed Dec 31 23:59:18 1969 +0000'
+    >>> datestr((0x7fffffff, 0))
+    'Tue Jan 19 03:14:07 2038 +0000'
+    >>> datestr((-0x7fffffff, 0))
+    'Fri Dec 13 20:45:53 1901 +0000'
+    """
     t, tz = date or makedate()
     if "%1" in format or "%2" in format or "%z" in format:
         sign = (tz > 0) and "-" or "+"


More information about the Mercurial-devel mailing list