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

Yuya Nishihara yuya at tcha.org
Tue Apr 12 10:19:09 EDT 2016


On Mon, 11 Apr 2016 19:54:55 +0200, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1460396810 -7200
> # Node ID 9e883d780661cf2ef47ca9ade115fd94f287be5b
> # Parent  3819c349b1947964573e014a36c00801356d4123
> util: add doctest to datestr()

Queued, thanks.

> 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'

I've updated the last example to use -0x80000000 to follow up Florent's patch.


More information about the Mercurial-devel mailing list