Mercurial > hg
comparison mercurial/util.py @ 1991:a8a618c57690
merge with self
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Thu, 23 Mar 2006 23:55:51 +0100 |
parents | 4b0535c678d6 04c17fc39c84 |
children | 6328445b0e71 |
comparison
equal
deleted
inserted
replaced
1990:4b0535c678d6 | 1991:a8a618c57690 |
---|---|
749 tz = time.altzone | 749 tz = time.altzone |
750 else: | 750 else: |
751 tz = time.timezone | 751 tz = time.timezone |
752 return time.mktime(lt), tz | 752 return time.mktime(lt), tz |
753 | 753 |
754 def datestr(date=None, format='%a %b %d %H:%M:%S %Y'): | 754 def datestr(date=None, format='%a %b %d %H:%M:%S %Y', timezone=True): |
755 """represent a (unixtime, offset) tuple as a localized time. | 755 """represent a (unixtime, offset) tuple as a localized time. |
756 unixtime is seconds since the epoch, and offset is the time zone's | 756 unixtime is seconds since the epoch, and offset is the time zone's |
757 number of seconds away from UTC.""" | 757 number of seconds away from UTC. if timezone is false, do not |
758 append time zone to string.""" | |
758 t, tz = date or makedate() | 759 t, tz = date or makedate() |
759 return ("%s %+03d%02d" % | 760 s = time.strftime(format, time.gmtime(float(t) - tz)) |
760 (time.strftime(format, time.gmtime(float(t) - tz)), | 761 if timezone: |
761 -tz / 3600, | 762 s += " %+03d%02d" % (-tz / 3600, ((-tz % 3600) / 60)) |
762 ((-tz % 3600) / 60))) | 763 return s |
763 | 764 |
764 def shortuser(user): | 765 def shortuser(user): |
765 """Return a short representation of a user name or email address.""" | 766 """Return a short representation of a user name or email address.""" |
766 f = user.find('@') | 767 f = user.find('@') |
767 if f >= 0: | 768 if f >= 0: |