Force timezone offset to LocalTimeZone on POT-Creation-Date that was generated by gettext builder. refs #1182

This commit is contained in:
Takayuki Shimizukawa 2013-06-13 12:54:05 +09:00
parent dbe60b4e02
commit c79e11a5c9
2 changed files with 14 additions and 13 deletions

View File

@ -9,8 +9,8 @@ Features added
Incompatible changes Incompatible changes
-------------------- --------------------
* PR#144, #1182: Force timezone offset to UTC on POT-Creation-Date that was * PR#144, #1182: Force timezone offset to LocalTimeZone on POT-Creation-Date
generated by gettext builder. Thanks to masklinn. that was generated by gettext builder. Thanks to masklinn and Jakub Wilk.
Bugs fixed Bugs fixed
---------- ----------

View File

@ -11,6 +11,7 @@
from os import path, walk from os import path, walk
from codecs import open from codecs import open
from time import time
from datetime import datetime, tzinfo, timedelta from datetime import datetime, tzinfo, timedelta
from collections import defaultdict from collections import defaultdict
from uuid import uuid4 from uuid import uuid4
@ -107,21 +108,22 @@ class I18nBuilder(Builder):
catalog.add(m, node) catalog.add(m, node)
ZERO = timedelta(0) class LocalTimeZone(tzinfo):
class UTC(tzinfo): def __init__(self, *args, **kw):
"""UTC""" super(LocalTimeZone, self).__init__(*args, **kw)
timestamp = time()
tzdelta = datetime.fromtimestamp(timestamp) - \
datetime.utcfromtimestamp(timestamp)
self.tzdelta = tzdelta
def utcoffset(self, dt): def utcoffset(self, dt):
return ZERO return self.tzdelta
def tzname(self, dt):
return "UTC"
def dst(self, dt): def dst(self, dt):
return ZERO return timedelta(0)
utc = UTC() ltz = LocalTimeZone()
class MessageCatalogBuilder(I18nBuilder): class MessageCatalogBuilder(I18nBuilder):
@ -171,8 +173,7 @@ class MessageCatalogBuilder(I18nBuilder):
version = self.config.version, version = self.config.version,
copyright = self.config.copyright, copyright = self.config.copyright,
project = self.config.project, project = self.config.project,
# XXX should supply tz ctime = datetime.now(ltz).strftime('%Y-%m-%d %H:%M%z'),
ctime = datetime.now(utc).strftime('%Y-%m-%d %H:%M%z'),
) )
for textdomain, catalog in self.status_iterator( for textdomain, catalog in self.status_iterator(
self.catalogs.iteritems(), "writing message catalogs... ", self.catalogs.iteritems(), "writing message catalogs... ",