int(tzoffset[2:]))
dt = datetime.fromtimestamp(ts)
self.creation_date = dt.replace(tzinfo=tzoffset)
+ elif name == 'po-revision-date':
+ # Keep the value if it's not the default one
+ if 'YEAR' not in value:
+ # FIXME: this should use dates.parse_datetime as soon as
+ # that is ready
+ value, tzoffset, _ = re.split('[+-](\d{4})$', value, 1)
+ tt = time.strptime(value, '%Y-%m-%d %H:%M')
+ ts = time.mktime(tt)
+ tzoffset = FixedOffsetTimezone(int(tzoffset[:2]) * 60 +
+ int(tzoffset[2:]))
+ dt = datetime.fromtimestamp(ts)
+ self.revision_date = dt.replace(tzinfo=tzoffset)
mime_headers = property(_get_mime_headers, _set_mime_headers, doc="""\
The MIME headers of the catalog, used for the special ``msgid ""`` entry.
localized_catalog.update(template)
self.assertEqual(template.creation_date,
localized_catalog.creation_date)
+
+ def test_update_po_keeps_po_revision_date(self):
+ template = catalog.Catalog()
+ localized_catalog = copy.deepcopy(template)
+ localized_catalog.locale = 'de_DE'
+ fake_rev_date = datetime.datetime.now() - datetime.timedelta(days=5)
+ localized_catalog.revision_date = fake_rev_date
+ self.assertNotEqual(template.mime_headers,
+ localized_catalog.mime_headers)
+ self.assertEqual(template.creation_date,
+ localized_catalog.creation_date)
+ template.creation_date = datetime.datetime.now() - \
+ datetime.timedelta(minutes=5)
+ localized_catalog.update(template)
+ self.assertEqual(localized_catalog.revision_date, fake_rev_date)
def suite():
locale = Locale(_locale)
date = format_datetime(datetime.now(LOCALTZ),
'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
+ tzinfo=LOCALTZ, locale=_locale)
except UnknownLocaleError:
# Just an alias? Not what we're testing here, let's continue
continue