Can specify date format in dyn:date

This commit is contained in:
Grégory Soutadé 2013-01-13 18:55:20 +01:00
parent 179fc3da2f
commit 5b3eafe758

View File

@ -22,6 +22,7 @@ class Index(DynastieGenerator):
self.hooks = {'posts' : self.createPosts, self.hooks = {'posts' : self.createPosts,
'title' : self.createTitle, 'title' : self.createTitle,
'date' : self.createDate,
'navigation' : self.createNavigation, 'navigation' : self.createNavigation,
'recents' : self.createRecents, 'recents' : self.createRecents,
'tags' : self.createTags, 'tags' : self.createTags,
@ -106,6 +107,16 @@ class Index(DynastieGenerator):
root.replaceChild(node, title_elem) root.replaceChild(node, title_elem)
def createDate(self, posts, dom, root, date_elem):
date_format = date_elem.getAttribute('format')
if date_format == '':
date_format = '%A, %d %B %Y %H:%m'
post = self.cur_post_obj
node = self.createElement(dom, 'date', post.creation_date.strftime(date_format))
root.replaceChild(node, date_elem)
def createPost(self, posts, dom, post_elem, root): def createPost(self, posts, dom, post_elem, root):
post = self.cur_post_obj post = self.cur_post_obj
@ -115,7 +126,6 @@ class Index(DynastieGenerator):
values = {} values = {}
values['author'] = post.author.first_name + ' ' + post.author.last_name values['author'] = post.author.first_name + ' ' + post.author.last_name
values['date'] = post.creation_date.strftime('%A, %d %B %Y %H:%m')
values['post_content'] = '' values['post_content'] = ''
blog = post.blog blog = post.blog