Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: filters/datesort.py

Issue 29334171: Issue 3410 - Added date sort / format for press releases (Closed)
Patch Set: Changed teamsort to be consistent with fixed import Created Feb. 4, 2016, 11:17 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | filters/humanize_date.py » ('j') | filters/humanize_date.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import datetime, random 1 def datesort(collection):
2 2 return sorted(collection, reverse=True)
3 def datesort(value, basedate="1970-01-01", column=0):
4 base = datetime.datetime.strptime(basedate, "%Y-%m-%d")
5 def randdiff(entry):
6 date = datetime.datetime.strptime(entry[column], "%Y-%m-%d")
7 diff = (date - base).days
8 return diff * 0.2 + random.randrange(diff) * 0.8
9 return sorted(value, key=randdiff)
OLDNEW
« no previous file with comments | « no previous file | filters/humanize_date.py » ('j') | filters/humanize_date.py » ('J')

Powered by Google App Engine
This is Rietveld