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

Side by Side Diff: filters/humandates.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.
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/randomsortbydate.py » ('j') | filters/randomsortbydate.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
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.
2 from datetime import datetime
3
4 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
5 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.
6 for item in collection:
7 item[0] = datetime.strftime(datetime.strptime(item[0], inputFormat), outpu tFormat)
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
8 return sorted(collection, reverse=True, key=lambda date: datetime.strptime(dat e[0], outputFormat))
OLDNEW
« no previous file with comments | « no previous file | filters/randomsortbydate.py » ('j') | filters/randomsortbydate.py » ('J')

Powered by Google App Engine
This is Rietveld