From 823da240d845715113e6e27ca4d339d12f953240 Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Tue, 7 Sep 2010 12:03:31 +0000 Subject: [PATCH] Change datetime conversion to handle TZ The way it happens now, the timezone gets corrected svn path=/plone.app.discussion/trunk/; revision=39728 --- plone/app/discussion/browser/comments.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 6aa1248..55ff7b0 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -164,7 +164,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form): comment.author_name = author_name comment.author_email = author_email #comment.author_notification = author_notification - comment.creation_date = comment.modification_date = datetime.now() + comment.creation_date = comment.modification_date = datetime.utcnow() elif not portal_membership.isAnonymousUser(): member = portal_membership.getAuthenticatedMember() comment.creator = member.id @@ -172,7 +172,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form): comment.author_name = member.getProperty('fullname') comment.author_email = member.getProperty('email') #comment.author_notification = comment.author_notification - comment.creation_date = comment.modification_date = datetime.now() + comment.creation_date = comment.modification_date = datetime.utcnow() else: raise Unauthorized, "Anonymous user tries to post a comment, but \ anonymous commenting is disabled." @@ -349,10 +349,5 @@ class CommentsViewlet(ViewletBase): # We have to transform Python datetime into Zope DateTime # before we can call toLocalizedTime. util = getToolByName(self.context, 'translation_service') - zope_time = DateTime(time.year, - time.month, - time.day, - time.hour, - time.minute, - time.second) + zope_time = DateTime(time.isoformat()) return util.toLocalizedTime(zope_time, long_format=True)