Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 6229:c3182eeb70ea
dates: improve timezone handling
datestr:
- add format specifiers %1 and %2 for timezone hours and minutes
- remove timezone and timezone format options
- correctly find timezone hours and minutes for fractional and negative timezones
- update users
strdate:
- correctly find timezone hours and minutes for fractional and negative timezones
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 11 Mar 2008 17:42:41 -0500 |
parents | 434139080ed4 |
children | 8999d1249171 |
comparison
equal
deleted
inserted
replaced
6228:c0c4c7b1e8d3 | 6229:c3182eeb70ea |
---|---|
67 try: | 67 try: |
68 return text.splitlines(1)[0].rstrip('\r\n') | 68 return text.splitlines(1)[0].rstrip('\r\n') |
69 except IndexError: | 69 except IndexError: |
70 return '' | 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 def nl2br(text): | 72 def nl2br(text): |
81 '''replace raw newlines with xhtml line breaks.''' | 73 '''replace raw newlines with xhtml line breaks.''' |
82 return text.replace('\n', '<br/>\n') | 74 return text.replace('\n', '<br/>\n') |
83 | 75 |
84 def obfuscate(text): | 76 def obfuscate(text): |
140 "escape": lambda x: cgi.escape(x, True), | 132 "escape": lambda x: cgi.escape(x, True), |
141 "fill68": lambda x: fill(x, width=68), | 133 "fill68": lambda x: fill(x, width=68), |
142 "fill76": lambda x: fill(x, width=76), | 134 "fill76": lambda x: fill(x, width=76), |
143 "firstline": firstline, | 135 "firstline": firstline, |
144 "tabindent": lambda x: indent(x, '\t'), | 136 "tabindent": lambda x: indent(x, '\t'), |
145 "hgdate": hgdate, | 137 "hgdate": lambda x: "%d %d" % x, |
146 "isodate": isodate, | 138 "isodate": lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2'), |
147 "obfuscate": obfuscate, | 139 "obfuscate": obfuscate, |
148 "permissions": permissions, | 140 "permissions": permissions, |
149 "person": person, | 141 "person": person, |
150 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | 142 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"), |
151 "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), | 143 "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"), |
152 "short": lambda x: x[:12], | 144 "short": lambda x: x[:12], |
153 "shortdate": util.shortdate, | 145 "shortdate": util.shortdate, |
154 "stringify": templater.stringify, | 146 "stringify": templater.stringify, |
155 "strip": lambda x: x.strip(), | 147 "strip": lambda x: x.strip(), |
156 "urlescape": lambda x: urllib.quote(x), | 148 "urlescape": lambda x: urllib.quote(x), |