mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-03-30 01:35:27 +00:00
refactor: crash in timestamp formatting when timezone_offset is none
In `Timing.format_timestamp`, if `self.timezone_offset` is `None` (which is explicitly allowed by the `Optional[int]` type hint), it instantiates `TimeZone(None)`. When `datetime.fromtimestamp()` calls the `utcoffset()` method on this timezone object, it executes `timedelta(hours=self.offset)`, which evaluates to `timedelta(hours=None)`. This raises a `TypeError: unsupported type for timedelta hours component: NoneType`, causing the application to crash during export. Affected files: data_model.py Signed-off-by: Tang Vu <vuminhtang2212@gmail.com>
This commit is contained in:
@@ -30,7 +30,8 @@ class Timing:
|
||||
"""
|
||||
if timestamp is not None:
|
||||
timestamp = timestamp / 1000 if timestamp > 9999999999 else timestamp
|
||||
return datetime.fromtimestamp(timestamp, TimeZone(self.timezone_offset)).strftime(format)
|
||||
tz = TimeZone(self.timezone_offset) if self.timezone_offset is not None else None
|
||||
return datetime.fromtimestamp(timestamp, tz).strftime(format)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user