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

Unified Diff: filters/randomsortbydate.py

Issue 29334171: Issue 3410 - Added date sort / format for press releases (Closed)
Patch Set: Fixed rename, typos, and function names Created Jan. 25, 2016, 4:18 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: filters/randomsortbydate.py
===================================================================
rename from filters/datesort.py
rename to filters/randomsortbydate.py
--- a/filters/datesort.py
+++ b/filters/randomsortbydate.py
@@ -1,9 +1,11 @@
-import datetime, random
saroyanm 2016/02/01 16:24:54 Detail: No new line needed in the beginning of the
Sebastian Noack 2016/02/01 18:01:23 It seems the changes in here (except for the funct
juliandoucette 2016/02/02 16:44:45 Done.
juliandoucette 2016/02/02 16:44:46 Done.
-def datesort(value, basedate="1970-01-01", column=0):
- base = datetime.datetime.strptime(basedate, "%Y-%m-%d")
+import random
+from datetime import datetime
+
+def randomsortbydate(value, basedate="1970-01-01", column=0):
+ base = datetime.strptime(basedate, "%Y-%m-%d")
def randdiff(entry):
- date = datetime.datetime.strptime(entry[column], "%Y-%m-%d")
+ date = datetime.strptime(entry[column], "%Y-%m-%d")
diff = (date - base).days
return diff * 0.2 + random.randrange(diff) * 0.8
return sorted(value, key=randdiff)

Powered by Google App Engine
This is Rietveld