|
1 | 1 | ## python-exiv2 - Python interface to libexiv2 |
2 | 2 | ## http://github.com/jim-easterbrook/python-exiv2 |
3 | | -## Copyright (C) 2023-25 Jim Easterbrook jim@jim-easterbrook.me.uk |
| 3 | +## Copyright (C) 2023-26 Jim Easterbrook jim@jim-easterbrook.me.uk |
4 | 4 | ## |
5 | 5 | ## This program is free software: you can redistribute it and/or |
6 | 6 | ## modify it under the terms of the GNU General Public License as |
|
23 | 23 | import random |
24 | 24 | import struct |
25 | 25 | import sys |
| 26 | +import time |
26 | 27 | import unittest |
27 | 28 |
|
28 | 29 | import exiv2 |
@@ -414,8 +415,8 @@ def do_test_DateValue(self, py_date): |
414 | 415 | self.assertEqual(str(value), py_date.isoformat()) |
415 | 416 | value.setDate(py_date.year, py_date.month, py_date.day) |
416 | 417 | self.assertEqual(str(value), py_date.isoformat()) |
417 | | - seconds = int(datetime.datetime.combine( |
418 | | - py_date, datetime.time(), datetime.timezone.utc).timestamp()) |
| 418 | + seconds = time.mktime(time.struct_time( |
| 419 | + (py_date.year, py_date.month, py_date.day, 0, 0, 0, 0, 0, 0))) |
419 | 420 | self.do_common_tests(value, exiv2.TypeId.date, py_date.isoformat(), data) |
420 | 421 | self.do_conversion_tests(value, py_date.isoformat(), seconds) |
421 | 422 | self.do_dataarea_tests(value) |
@@ -491,9 +492,9 @@ def do_test_TimeValue(self, py_time): |
491 | 492 | value.setTime(py_time.hour, py_time.minute, py_time.second, 1) |
492 | 493 | value.setTime(py_time.hour, py_time.minute, py_time.second, 1, 30) |
493 | 494 | self.assertEqual(str(value), py_time.isoformat()) |
494 | | - seconds = (py_time.hour * 3600) + (py_time.minute * 60) + py_time.second |
495 | | - seconds -= py_time.tzinfo.utcoffset( |
496 | | - datetime.datetime.now()).total_seconds() |
| 495 | + seconds = (((exiv_time.hour - exiv_time.tzHour) * 3600) + |
| 496 | + ((exiv_time.minute - exiv_time.tzMinute) * 60) + |
| 497 | + exiv_time.second) |
497 | 498 | if seconds < 0: |
498 | 499 | seconds += 24 * 3600 |
499 | 500 | value = exiv2.TimeValue() |
|
0 commit comments