Skip to content

Commit

Permalink
Model: Day, month and year for custom filename (bug 1768)
Browse files Browse the repository at this point in the history
Users can now use the following fields to customize the
sync filename when using MP3 player device sync:

  {episode.pubdate_year} - Year of publication (without century)
  {episode.pubdate_month} - Month of publication (01-12)
  {episode.pubdate_day} - Day of publication (01-31)

In addition to these fields, {episode.sortdate} is still
provided and gives YYYY-MM-DD as result (just like before).
  • Loading branch information
thp committed Feb 12, 2013
1 parent 5256652 commit 2e7417d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/gpodder/model.py
Expand Up @@ -682,9 +682,24 @@ def cute_pubdate(self):

pubdate_prop = property(fget=cute_pubdate)

def published_datetime(self):
return datetime.datetime.fromtimestamp(self.published)

@property
def sortdate(self):
return str(datetime.datetime.fromtimestamp(self.published).strftime('%F'))
return self.published_datetime().strftime('%F')

@property
def pubdate_day(self):
return self.published_datetime().strftime('%d')

@property
def pubdate_month(self):
return self.published_datetime().strftime('%m')

@property
def pubdate_year(self):
return self.published_datetime().strftime('%y')

def is_finished(self):
"""Return True if this episode is considered "finished playing"
Expand Down

0 comments on commit 2e7417d

Please sign in to comment.