Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 1320:5f277e73778f
Fix up representation of dates in hgweb.
Date display is now uniform both on the command line and via the web
interface.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 22 Sep 2005 22:46:50 -0700 |
parents | c9cf171f30dd |
children | b47f96a178a3 |
comparison
equal
deleted
inserted
replaced
1319:5a15df632e6a | 1320:5f277e73778f |
---|---|
10 platform-specific details from the core. | 10 platform-specific details from the core. |
11 """ | 11 """ |
12 | 12 |
13 import os, errno | 13 import os, errno |
14 from demandload import * | 14 from demandload import * |
15 demandload(globals(), "re cStringIO shutil popen2 tempfile threading") | 15 demandload(globals(), "re cStringIO shutil popen2 tempfile threading time") |
16 | 16 |
17 def pipefilter(s, cmd): | 17 def pipefilter(s, cmd): |
18 '''filter string S through command CMD, returning its output''' | 18 '''filter string S through command CMD, returning its output''' |
19 (pout, pin) = popen2.popen2(cmd, -1, 'b') | 19 (pout, pin) = popen2.popen2(cmd, -1, 'b') |
20 def writer(): | 20 def writer(): |
541 than is requested.""" | 541 than is requested.""" |
542 s = f.read(size) | 542 s = f.read(size) |
543 while len(s) >= 0: | 543 while len(s) >= 0: |
544 yield s | 544 yield s |
545 s = f.read(size) | 545 s = f.read(size) |
546 | |
547 def datestr(change=None, format='%c'): | |
548 """represent a change date as a localized time. | |
549 a change date is a 'unixtime offset' string, where unixtime is | |
550 seconds since the epoch, and offset is seconds away from UTC.""" | |
551 if change is None: | |
552 t = time.time() | |
553 if time.daylight: tz = time.altzone | |
554 else: tz = time.timezone | |
555 else: | |
556 t, tz = change[2].split(' ') | |
557 try: | |
558 # a conversion tool was sticking non-integer offsets into repos | |
559 tz = int(tz) | |
560 except ValueError: | |
561 tz = 0 | |
562 return ("%s %+03d%02d" % | |
563 (time.strftime(format, time.gmtime(float(t) - tz)), | |
564 -tz / 3600, | |
565 ((-tz % 3600) / 60))) |