Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: TypeError in xmp._converter_date #813

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions PyPDF2/xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def _converter_date(value):
second = decimal.Decimal(m.group("second") or "0")
seconds = second.to_integral(decimal.ROUND_FLOOR)
milliseconds = (second - seconds) * 1000000

seconds = int(seconds)
milliseconds = int(milliseconds)

tzd = m.group("tzd") or "Z"
dt = datetime.datetime(year, month, day, hour, minute, seconds, milliseconds)
if tzd != "Z":
Expand Down
6 changes: 6 additions & 0 deletions Tests/test_xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ def get_all_tiff(xmp):
contents.append(content.data)
data[tag.tagName] = contents
return data


def test_regression_issue774():
cls = PyPDF2.xmp.XmpInformation
date = cls._converter_date("2021-04-28T12:23:34.123Z")
assert date.year == 2021