| Index: filters/humandates.py |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/filters/humandates.py |
| @@ -0,0 +1,8 @@ |
| + |
|
saroyanm
2016/02/01 16:24:54
Detail: No new line needed in the beginning of the
juliandoucette
2016/02/02 16:44:45
Done.
|
| +from datetime import datetime |
| + |
| +def humandates(collection, inputFormat='%Y-%m-%d', outputFormat='%B %d, %Y'): |
|
saroyanm
2016/02/01 16:24:54
Not really sure if naming this function as human d
juliandoucette
2016/02/02 16:44:45
I changed it because it did more than sort.
In th
|
| + if inputFormat != outputFormat: |
|
Sebastian Noack
2016/02/01 18:01:22
This check is redundant. No need for premature mic
juliandoucette
2016/02/02 16:44:45
Done.
|
| + for item in collection: |
| + item[0] = datetime.strftime(datetime.strptime(item[0], inputFormat), outputFormat) |
|
Sebastian Noack
2016/02/01 18:01:23
A filter changing it's input in-place is quite une
juliandoucette
2016/02/02 16:44:45
I agree. In the next patch I will manipulate a cop
|
| + return sorted(collection, reverse=True, key=lambda date: datetime.strptime(date[0], outputFormat)) |