[PATCH] Add support for english date names on non-english systems

Yuya Nishihara yuya at tcha.org
Tue Feb 24 09:26:14 CST 2015


On Tue, 24 Feb 2015 14:22:20 +0100, A. Klitzing wrote:
> We have here a jenkins with build jobs on different slaves that will do
> some operations with "dates" parameter. Some systems uses English locale
> and some systems uses German locale. So we needed to configure the job to
> uses other date names.
> 
> As this is really annoying to keep the systems locale in mind for some
> operations I looked into util.py. It would be helpful for automated systems
> if the "default English" date names would even usable on other locales.
> 
> I attached a simple patch for this.

You should include these in commit messages.

http://mercurial.selenic.com/wiki/ContributingChanges

> # HG changeset patch
> # User André Klitzing <aklitzing at gmail.com>
> # Date 1424783533 -3600
> #      Tue Feb 24 14:12:13 2015 +0100
> # Node ID 090f886be9c7b29b39d48afbe6c612f0914dff0c
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> util: accept "now, today, yesterday" for dates even the locale is not english
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1350,11 +1350,11 @@
>          formats = defaultdateformats
>      date = date.strip()
>  
> -    if date == _('now'):
> +    if date == 'now' or date == _('now'):
>          return makedate()
> -    if date == _('today'):
> +    if date == 'today' or date == _('today'):
>          date = datetime.date.today().strftime('%b %d')
> -    elif date == _('yesterday'):
> +    elif date == 'yesterday' or date == _('yesterday'):
>          date = (datetime.date.today() -
>                  datetime.timedelta(days=1)).strftime('%b %d')

I like this and I found it works out of the box for LANG=ja probably because
foozy doesn't translate these words purposely.

Regards,


More information about the Mercurial-devel mailing list