how to get UTC timestamp for commit?

Olaf Hering olaf at aepfle.de
Mon Aug 17 08:18:06 UTC 2015


Assume this output:

 # mutt-hg $ hg log | head -n 4
 # changeset:   6479:55ea6e829b46
 # tag:         tip
 # user:        Kevin McCarthy <kevin at 8t8.us>
 # date:        Tue Aug 11 11:20:15 2015 -0700

I want to get the UTC date of this commit, like:

 # mutt-hg $ hg tip --template "{date(date, '%Y%m%dT%H%M%S')}.r{rev}\n"
 # 20150811T112015.r6479

But it is reported as localtime. Looking through "hg help templates" I see a
reference to "hg help dates":

        date(date[, fmt])
                Format a date. See "hg help dates" for formatting strings.

But that does not contain a list of formating strings as output, just various
formats for input.

What is the format string to report UTC time? I do not have control over how
hg(1) is invoked. All I can do is to pass options to --template.

Thanks,

Olaf


More information about the Mercurial mailing list