how to get UTC timestamp for commit?

Yuya Nishihara yuya at tcha.org
Wed Aug 19 11:40:58 UTC 2015


On Tue, 18 Aug 2015 23:32:03 +0100, Christian Ebert wrote:
> * Matt Mackall on Tuesday, August 18, 2015 at 16:57:05 -0500
> > On Tue, 2015-08-18 at 22:33 +0100, Christian Ebert wrote:
> >> * Matt Mackall on Tuesday, August 18, 2015 at 12:40:30 -0500
> >>> On Tue, 2015-08-18 at 03:32 +0100, Christian Ebert wrote:
> >>>> The keyword extension provides an utcdate filter:
> >>>> 
> >>>> $ hg --config extensions.keyword= log -l1 --template '{date|utcdate}\n'
> >>>> 2015/08/16 18:24:30
> >>>> 
> >>>> The code looks like this:
> >>>> # date like in cvs' $Date
> >>>> def utcdate(text):
> >>>>   ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13".
> >>>>   '''
> >>>>   return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S')
> >>>> 
> >>>> 
> >>>> Maybe that helps.
> >>> 
> >>> That's a silly place for it?
> >> 
> >> I offered to make this available in core, but it wasn't deemed
> >> necessary. Maybe because of the '%Y/%m/%d %H:%M:%S' format, I
> >> don't know.
> > 
> > Ahh, right. What's really wanted is an analog to localdate: don't format
> > the date, just change the timezone. IOW:
> > 
> > def utcdate(date):
> >    return (date[0], 0)
> > 
> > But now we have a name collision.
> 
> I know. But core should have priority. Maybe there's a pragmatic
> way to deal with a bit of BC breakage. One could argue that no
> crucial data breaks ...

What about localdate(date[, utcoffset]) ?

  {date|localdate}      # local timezone
  {localdate(date, 0)}  # utc



More information about the Mercurial mailing list