clalancette / pycdlib

Python library to read and write ISOs
GNU Lesser General Public License v2.1
143 stars 38 forks source link

Handle dates at year boundary #108

Closed lod closed 1 year ago

lod commented 1 year ago

Fixes 117

Rework gmtoffset_from_tm to use seconds based maths

utkonos commented 1 year ago

This patch changes the error to a different error, but doesn't fix it for me.

>>> import pycdlib
>>> iso = pycdlib.PyCdlib()
>>> iso.new(rock_ridge='1.09', vol_ident='CIDATA')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lab/lib/python3.11/site-packages/pycdlib/pycdlib.py", line 3895, in new
    self.pvd = headervd.pvd_factory(sys_ident_bytes, vol_ident_bytes,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lab/lib/python3.11/site-packages/pycdlib/headervd.py", line 809, in pvd_factory
    pvd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
  File "/lab/lib/python3.11/site-packages/pycdlib/headervd.py", line 318, in new
    self.volume_creation_date.new(now)
  File "/lab/lib/python3.11/site-packages/pycdlib/dates.py", line 256, in new
    self.date_str = time.strftime(self.TIME_FMT, local).encode('utf-8') + '{:0<2}'.format(self.hundredthsofsecond).encode('utf-8') + struct.pack('=b', self.gmtoffset)
                                                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: required argument is not an integer
utkonos commented 1 year ago
>>> import pycdlib
>>> iso = pycdlib.PyCdlib()
>>> iso.new(rock_ridge='1.09', vol_ident='CIDATA')
> /lab/lib/python3.11/site-packages/pycdlib/utils.py(223)gmtoffset_from_tm()
-> return offset_hours
(Pdb) type(offset_hours)
<class 'float'>
(Pdb) offset_hours
-5.0
(Pdb) int(offset_hours)
-5
clalancette commented 1 year ago

See my comment in https://github.com/clalancette/pycdlib/issues/107#issuecomment-1368573568 , where I fixed this a different way. Given that, I'm going to close this out. But thanks for the contribution!