mercurial/util.py
changeset 1987 04c17fc39c84
parent 1976 df8416346bb7
child 1991 a8a618c57690
equal deleted inserted replaced
1985:c577689006fa 1987:04c17fc39c84
   742         tz = time.altzone
   742         tz = time.altzone
   743     else:
   743     else:
   744         tz = time.timezone
   744         tz = time.timezone
   745     return time.mktime(lt), tz
   745     return time.mktime(lt), tz
   746 
   746 
   747 def datestr(date=None, format='%a %b %d %H:%M:%S %Y'):
   747 def datestr(date=None, format='%a %b %d %H:%M:%S %Y', timezone=True):
   748     """represent a (unixtime, offset) tuple as a localized time.
   748     """represent a (unixtime, offset) tuple as a localized time.
   749     unixtime is seconds since the epoch, and offset is the time zone's
   749     unixtime is seconds since the epoch, and offset is the time zone's
   750     number of seconds away from UTC."""
   750     number of seconds away from UTC. if timezone is false, do not
       
   751     append time zone to string."""
   751     t, tz = date or makedate()
   752     t, tz = date or makedate()
   752     return ("%s %+03d%02d" %
   753     s = time.strftime(format, time.gmtime(float(t) - tz))
   753             (time.strftime(format, time.gmtime(float(t) - tz)),
   754     if timezone:
   754              -tz / 3600,
   755         s += " %+03d%02d" % (-tz / 3600, ((-tz % 3600) / 60))
   755              ((-tz % 3600) / 60)))
   756     return s
   756 
   757 
   757 def shortuser(user):
   758 def shortuser(user):
   758     """Return a short representation of a user name or email address."""
   759     """Return a short representation of a user name or email address."""
   759     f = user.find('@')
   760     f = user.find('@')
   760     if f >= 0:
   761     if f >= 0: