Cannot assign dates earlier than the year 1900

Bug #797626 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
Medium
Olivier Tilloy

Bug Description

(originally spotted by Rob Healey, thanks Rob!)

Script to reproduce, with any image file:

import pyexiv2
from datetime import datetime
m = pyexiv2.ImageMetadata("image.jpg")
m.read()
m['Exif.Image.DateTime'] = datetime(1899, 12, 31, 23, 59, 59)

Expected result: assigning the datetime works.

Current result: fail with a ValueError: "ValueError: year=1899 is before 1900; the datetime strftime() methods require year >= 1900"

Revision history for this message
Olivier Tilloy (osomon) wrote :

Note that the first camera was created at the beginning of the 19th century, so pyexiv2 needs to be able to process dates < 1900.

Revision history for this message
Olivier Tilloy (osomon) wrote :

From the Python docs: « The exact range of years for which strftime() works also varies across platforms. Regardless of platform, years before 1900 cannot be used. » (see http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior).

There may be a way to overcome this limitation by not using strftime.

Olivier Tilloy (osomon)
Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
status: Confirmed → In Progress
Revision history for this message
Olivier Tilloy (osomon) wrote :

Fixed at revision 360 of lp:~osomon/pyexiv2/pyexiv2-0.3.

Changed in pyexiv2:
status: In Progress → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
milestone: none → 0.3.1
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.