warcio icon indicating copy to clipboard operation
warcio copied to clipboard

Timezone offset TypeError fixed

Open FabioKn opened this issue 7 months ago • 2 comments

The previous implementation raised a TypeError

line 70, in iso_date_to_datetime 
the_datetime = datetime(*(int(num) for num in nums), tzinfo=tzinfo)
TypeError: function takes at most 9 arguments (10 given)

when the ISO date string included a timezone offset.

This is now resolved by using datetime.fromisoformat, which correctly handles timezone-aware ISO strings.

if not tz_aware:
        the_datetime = the_datetime.replace(tzinfo=None)

handles the tz_aware flag and ensures downward compatibility

added two Docstringtests for Offset

FabioKn avatar May 08 '25 14:05 FabioKn

This fix is relevant for the usage in har2warc. har2warc fails with the above-mentioned error in the following lines:

https://github.com/webrecorder/har2warc/blob/dd1e29a0af018113ffbd19795ee6bc390b8889c2/har2warc/har2warc.py#L85-L87

This happens with .har files generated by firefox/librewolf as e.g. the one in the attached ZIP-file.

example-org.har.zip

white-gecko avatar May 08 '25 14:05 white-gecko

@FabioKn can you show us how you triggered this error? Was it reading a warc file, etc

Oh, I see that you work with @white-gecko and that is the trigger. Thanks.

wumpus avatar May 12 '25 17:05 wumpus