Alternate, and one hopes better, implementation of clean sort. This implementation does not alter the timezone.

This commit is contained in:
Charles Haley 2011-11-14 08:28:14 +01:00
parent 6859477f1f
commit 6ff72bbcae

View File

@ -291,10 +291,6 @@ def clean_date_for_sort(dt, format):
if not isinstance(dt, datetime):
dt = datetime.combine(dt, time())
if hasattr(dt, 'tzinfo'):
if dt.tzinfo is not None:
dt = as_local_time(dt)
if format == 'iso':
format = 'yyMdhms'
@ -304,7 +300,8 @@ def clean_date_for_sort(dt, format):
repl_func = partial(cd_repl_func, tt, dt)
re.sub('(s{1,2})|(m{1,2})|(h{1,2})|(d{1,4}|M{1,4}|(?:yyyy|yy))', repl_func, format)
return datetime(tt['year'], tt['mon'], tt['day'], tt['hour'], tt['min'], tt['sec'])
return dt.replace(year=tt['year'], month=tt['mon'], day=tt['day'], hour=tt['hour'],
minute=tt['min'], second=tt['sec'], microsecond=0)
def replace_months(datestr, clang):
# Replace months by english equivalent for parse_date