Ticket #2905: trac_2905.diff
| File trac_2905.diff, 1.4 KB (added by cmlenz, 3 years ago) |
|---|
-
trac/util/__init__.py
17 17 # Author: Jonas Borgström <jonas@edgewall.com> 18 18 # Matthew Good <trac@matt-good.net> 19 19 20 import locale 20 21 import md5 21 22 import os 22 23 import re … … 173 174 t = time.localtime(int(t)) 174 175 175 176 text = time.strftime(format, t) 176 return to_utf8(text) 177 encoding = locale.getlocale(locale.LC_TIME)[1] or \ 178 locale.getpreferredencoding() 179 return unicode(text, encoding, 'replace') 177 180 178 181 def format_date(t=None, format='%x', gmt=False): 179 182 return format_datetime(t, format, gmt) … … 184 187 def get_date_format_hint(): 185 188 t = time.localtime(0) 186 189 t = (1999, 10, 29, t[3], t[4], t[5], t[6], t[7], t[8]) 187 tmpl = time.strftime('%x',t)190 tmpl = format_date(t) 188 191 return tmpl.replace('1999', 'YYYY', 1).replace('99', 'YY', 1) \ 189 192 .replace('10', 'MM', 1).replace('29', 'DD', 1) 190 193 191 194 def get_datetime_format_hint(): 192 195 t = time.localtime(0) 193 196 t = (1999, 10, 29, 23, 59, 58, t[6], t[7], t[8]) 194 tmpl = time.strftime('%x %X',t)197 tmpl = format_datetime(t) 195 198 return tmpl.replace('1999', 'YYYY', 1).replace('99', 'YY', 1) \ 196 199 .replace('10', 'MM', 1).replace('29', 'DD', 1) \ 197 200 .replace('23', 'hh', 1).replace('59', 'mm', 1) \
