Show More
@@ -210,9 +210,7 b' class notifier(object):' | |||
|
210 | 210 | del msg['From'] |
|
211 | 211 | msg['From'] = sender |
|
212 | 212 | |
|
213 |
msg['Date'] = util.datestr( |
|
|
214 | format="%a, %d %b %Y %H:%M:%S", | |
|
215 | timezone=True) | |
|
213 | msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") | |
|
216 | 214 | fix_subject() |
|
217 | 215 | fix_sender() |
|
218 | 216 |
@@ -391,8 +391,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||
|
391 | 391 | m['In-Reply-To'] = parent |
|
392 | 392 | else: |
|
393 | 393 | parent = m['Message-Id'] |
|
394 |
m['Date'] = util.datestr( |
|
|
395 | format="%a, %d %b %Y %H:%M:%S", timezone=True) | |
|
394 | m['Date'] = util.datestr(start_time, "%a, %d %b %Y %H:%M:%S %1%2") | |
|
396 | 395 | |
|
397 | 396 | start_time = (start_time[0] + 1, start_time[1]) |
|
398 | 397 | m['From'] = sender |
@@ -419,8 +418,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||
|
419 | 418 | elif opts.get('mbox'): |
|
420 | 419 | ui.status('Writing ', m['Subject'], ' ...\n') |
|
421 | 420 | fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') |
|
422 |
date = util.datestr( |
|
|
423 | format='%a %b %d %H:%M:%S %Y', timezone=False) | |
|
421 | date = util.datestr(start_time, '%a %b %d %H:%M:%S %Y') | |
|
424 | 422 | fp.write('From %s %s\n' % (sender_addr, date)) |
|
425 | 423 | fp.write(m.as_string(0)) |
|
426 | 424 | fp.write('\n\n') |
@@ -69,14 +69,6 b' def firstline(text):' | |||
|
69 | 69 | except IndexError: |
|
70 | 70 | return '' |
|
71 | 71 | |
|
72 | def isodate(date): | |
|
73 | '''turn a (timestamp, tzoff) tuple into an iso 8631 date and time.''' | |
|
74 | return util.datestr(date, format='%Y-%m-%d %H:%M') | |
|
75 | ||
|
76 | def hgdate(date): | |
|
77 | '''turn a (timestamp, tzoff) tuple into an hg cset timestamp.''' | |
|
78 | return "%d %d" % date | |
|
79 | ||
|
80 | 72 | def nl2br(text): |
|
81 | 73 | '''replace raw newlines with xhtml line breaks.''' |
|
82 | 74 | return text.replace('\n', '<br/>\n') |
@@ -142,13 +134,13 b' filters = {' | |||
|
142 | 134 | "fill76": lambda x: fill(x, width=76), |
|
143 | 135 | "firstline": firstline, |
|
144 | 136 | "tabindent": lambda x: indent(x, '\t'), |
|
145 | "hgdate": hgdate, | |
|
146 | "isodate": isodate, | |
|
137 | "hgdate": lambda x: "%d %d" % x, | |
|
138 | "isodate": lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2'), | |
|
147 | 139 | "obfuscate": obfuscate, |
|
148 | 140 | "permissions": permissions, |
|
149 | 141 | "person": person, |
|
150 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | |
|
151 |
"rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S |
|
|
142 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"), | |
|
143 | "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"), | |
|
152 | 144 | "short": lambda x: x[:12], |
|
153 | 145 | "shortdate": util.shortdate, |
|
154 | 146 | "stringify": templater.stringify, |
@@ -1524,20 +1524,23 b' def makedate():' | |||
|
1524 | 1524 | tz = time.timezone |
|
1525 | 1525 | return time.mktime(lt), tz |
|
1526 | 1526 | |
|
1527 |
def datestr(date=None, format='%a %b %d %H:%M:%S %Y' |
|
|
1527 | def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): | |
|
1528 | 1528 | """represent a (unixtime, offset) tuple as a localized time. |
|
1529 | 1529 | unixtime is seconds since the epoch, and offset is the time zone's |
|
1530 | 1530 | number of seconds away from UTC. if timezone is false, do not |
|
1531 | 1531 | append time zone to string.""" |
|
1532 | 1532 | t, tz = date or makedate() |
|
1533 | if "%1" in format or "%2" in format: | |
|
1534 | sign = (tz > 0) and "-" or "+" | |
|
1535 | minutes = abs(tz) / 60 | |
|
1536 | format = format.replace("%1", "%c%02d" % (sign, minutes / 60)) | |
|
1537 | format = format.replace("%2", "%02d" % (minutes % 60)) | |
|
1533 | 1538 | s = time.strftime(format, time.gmtime(float(t) - tz)) |
|
1534 | if timezone: | |
|
1535 | s += timezone_format % (int(-tz / 3600.0), ((-tz % 3600) / 60)) | |
|
1536 | 1539 | return s |
|
1537 | 1540 | |
|
1538 | 1541 | def shortdate(date=None): |
|
1539 | 1542 | """turn (timestamp, tzoff) tuple into iso 8631 date.""" |
|
1540 |
return datestr(date, format='%Y-%m-%d' |
|
|
1543 | return datestr(date, format='%Y-%m-%d') | |
|
1541 | 1544 | |
|
1542 | 1545 | def strdate(string, format, defaults=[]): |
|
1543 | 1546 | """parse a localized time string and return a (unixtime, offset) tuple. |
@@ -1545,9 +1548,10 b' def strdate(string, format, defaults=[])' | |||
|
1545 | 1548 | def timezone(string): |
|
1546 | 1549 | tz = string.split()[-1] |
|
1547 | 1550 | if tz[0] in "+-" and len(tz) == 5 and tz[1:].isdigit(): |
|
1548 | tz = int(tz) | |
|
1549 | offset = - 3600 * (tz / 100) - 60 * (tz % 100) | |
|
1550 | return offset | |
|
1551 | sign = (tz[0] == "+") and 1 or -1 | |
|
1552 | hours = int(tz[1:3]) | |
|
1553 | minutes = int(tz[3:5]) | |
|
1554 | return -sign * (hours * 60 + minutes) * 60 | |
|
1551 | 1555 | if tz == "GMT" or tz == "UTC": |
|
1552 | 1556 | return 0 |
|
1553 | 1557 | return None |
@@ -1601,7 +1605,7 b' def parsedate(date, formats=None, defaul' | |||
|
1601 | 1605 | elif part[0] in "dm": |
|
1602 | 1606 | defaults[part] = "1" |
|
1603 | 1607 | else: |
|
1604 |
defaults[part] = datestr(now, "%" + part[0] |
|
|
1608 | defaults[part] = datestr(now, "%" + part[0]) | |
|
1605 | 1609 | |
|
1606 | 1610 | for format in formats: |
|
1607 | 1611 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now