View Single Post
Old 01-24-2010, 10:13 AM   #4
BrianG
Member
BrianG began at the beginning.
 
Posts: 23
Karma: 22
Join Date: Dec 2009
Device: Kindle DX
Add dates to Feed title

Here's a module that will add the earliest/latest feed dates to the title of the feed (and therefore the Table of Contents entry as well). Useful when feeds aren't updated on a regular basis ...

The GET_FEED_DATES procedure accepts a single feed object (not a list of feeds, but a FOR loop could deal with a list). It also accepts a date mask of the begin/end dates for use with STRFTIME.

Here's an example of calling the procedure:

Spoiler:
Code:
		# Append the earliest/latest dates of the feed to feed title
		startDate, endDate = self.get_feed_dates(feed, '%d-%b')
		newFeedTitle = feed.title + '  (' + startDate + ' thru ' + endDate + ')'


Here's the procedure itself:
Spoiler:
Code:
   def get_feed_dates(self, feedObject, dateMask):
	
	startDate = feedObject.articles[len(feedObject.articles)-1].localtime.strftime(dateMask)
	endDate   = feedObject.articles[0].localtime.strftime(dateMask)

	return startDate, endDate

Last edited by Starson17; 02-25-2011 at 09:07 PM.
BrianG is offline   Reply With Quote