aboutsummaryrefslogtreecommitdiffstats
path: root/test/iptc.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2011-08-12 08:33:38 +0200
committerOlivier Tilloy <olivier@tilloy.net>2011-08-12 08:33:38 +0200
commit8db919cfb2e31409116026d76a72e82f4f0824c1 (patch)
treeec913e0c133aac45ac9818bc3afc4942074d6817 /test/iptc.py
parent5d6fc27aa0dee1d9793b027a1215cc4c124cc7c9 (diff)
parentaecc90f8bc3c9739d818749fd1bc458884300148 (diff)
downloadpyexiv2-8db919cfb2e31409116026d76a72e82f4f0824c1.tar.gz
Allow assigning dates earlier than the year 1900.
This requires a custom DateTimeFormatter helper as Python’s strftime() doesn’t support years before 1900 (see http://docs.python.org/library/datetime.html#strftime-strptime-behavior for details).
Diffstat (limited to 'test/iptc.py')
-rw-r--r--test/iptc.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/iptc.py b/test/iptc.py
index ec631cb..c207f5a 100644
--- a/test/iptc.py
+++ b/test/iptc.py
@@ -108,12 +108,18 @@ class TestIptcTag(unittest.TestCase):
self.assertEqual(tag.type, 'Date')
self.assertEqual(tag._convert_to_string(datetime.date(2009, 2, 4)),
'2009-02-04')
+ self.assertEqual(tag._convert_to_string(datetime.date(1899, 12, 31)),
+ '1899-12-31')
self.assertEqual(tag._convert_to_string(datetime.datetime(1999, 10, 13)),
'1999-10-13')
self.assertEqual(tag._convert_to_string(datetime.datetime(2009, 2, 4)),
'2009-02-04')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31)),
+ '1899-12-31')
self.assertEqual(tag._convert_to_string(datetime.datetime(2009, 2, 4, 10, 52, 37)),
'2009-02-04')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59)),
+ '1899-12-31')
# Invalid values
self.failUnlessRaises(IptcValueError, tag._convert_to_string, 'invalid')
@@ -152,14 +158,24 @@ class TestIptcTag(unittest.TestCase):
'10:52:04+05:30')
self.assertEqual(tag._convert_to_string(datetime.time(10, 52, 4, tzinfo=FixedOffset('-', 4, 0))),
'10:52:04-04:00')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59)),
+ '23:59:59+00:00')
self.assertEqual(tag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4)),
'10:52:04+00:00')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59, 999)),
+ '23:59:59+00:00')
self.assertEqual(tag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, 478)),
'10:52:04+00:00')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59, tzinfo=FixedOffset())),
+ '23:59:59+00:00')
self.assertEqual(tag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset())),
'10:52:04+00:00')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59, tzinfo=FixedOffset('+', 5, 30))),
+ '23:59:59+05:30')
self.assertEqual(tag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset('+', 5, 30))),
'10:52:04+05:30')
+ self.assertEqual(tag._convert_to_string(datetime.datetime(1899, 12, 31, 23, 59, 59, tzinfo=FixedOffset('-', 4, 0))),
+ '23:59:59-04:00')
self.assertEqual(tag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset('-', 4, 0))),
'10:52:04-04:00')