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

Side by Side Diff: filters/rndsortbydate.py

Issue 29334171: Issue 3410 - Added date sort / format for press releases (Closed)
Patch Set: Created Jan. 20, 2016, 4:58 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
saroyanm 2016/01/22 11:58:14 no need to use short form of the words and abbrevi
saroyanm 2016/01/22 11:58:14 please use "hg rename" when renaming the files, so
juliandoucette 2016/01/25 16:19:55 Done.
juliandoucette 2016/01/25 16:19:55 Done.
2 import random
3 from datetime import datetime
4
5 def rndsortbydate(value, basedate="1970-01-01", column=0):
6 base =datetime.strptime(basedate, "%Y-%m-%d")
7 def randdiff(entry):
8 date = datetime.strptime(entry[column], "%Y-%m-%d")
9 diff = (date - base).days
10 return diff * 0.2 + random.randrange(diff) * 0.8
11 return sorted(value, key=randdiff)
12
OLDNEW

Powered by Google App Engine
This is Rietveld