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) |