diff --git a/Whatsapp_Chat_Exporter/android_handler.py b/Whatsapp_Chat_Exporter/android_handler.py index b10c40c..30cc2d9 100644 --- a/Whatsapp_Chat_Exporter/android_handler.py +++ b/Whatsapp_Chat_Exporter/android_handler.py @@ -12,7 +12,7 @@ from hashlib import sha256 from base64 import b64decode, b64encode from datetime import datetime from Whatsapp_Chat_Exporter.data_model import ChatStore, Message -from Whatsapp_Chat_Exporter.utility import MAX_SIZE, ROW_SIZE, DbType, convert_time_unit, determine_metadata +from Whatsapp_Chat_Exporter.utility import CURRENT_TZ_OFFSET, MAX_SIZE, ROW_SIZE, DbType, convert_time_unit, determine_metadata from Whatsapp_Chat_Exporter.utility import rendering, Crypt, Device, get_file_name, setup_template, JidType from Whatsapp_Chat_Exporter.utility import brute_force_offset, CRYPT14_OFFSETS, get_status_location from Whatsapp_Chat_Exporter.utility import get_chat_condition, slugify, bytes_to_readable, chat_is_empty @@ -354,7 +354,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat): timestamp=content["timestamp"], time=content["timestamp"], key_id=content["key_id"], - timezone_offset=timezone_offset + timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET ) if isinstance(content["data"], bytes): message.data = ("The message is binary data and its base64 is " @@ -717,7 +717,7 @@ def calls(db, data, timezone_offset, filter_chat): timestamp=content["timestamp"], time=content["timestamp"], key_id=content["call_id"], - timezone_offset=timezone_offset + timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET ) _jid = content["raw_string"] name = data[_jid].name if _jid in data else content["chat_subject"] or None diff --git a/Whatsapp_Chat_Exporter/ios_handler.py b/Whatsapp_Chat_Exporter/ios_handler.py index 0744f4f..566dd41 100644 --- a/Whatsapp_Chat_Exporter/ios_handler.py +++ b/Whatsapp_Chat_Exporter/ios_handler.py @@ -7,7 +7,7 @@ from pathlib import Path from mimetypes import MimeTypes from markupsafe import escape as htmle from Whatsapp_Chat_Exporter.data_model import ChatStore, Message -from Whatsapp_Chat_Exporter.utility import APPLE_TIME, Device, get_chat_condition, slugify +from Whatsapp_Chat_Exporter.utility import APPLE_TIME, CURRENT_TZ_OFFSET, Device, get_chat_condition, slugify def contacts(db, data): @@ -149,7 +149,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat): timestamp=ts, time=ts, # TODO: Could be bug key_id=content["ZSTANZAID"][:17], - timezone_offset=timezone_offset + timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET ) invalid = False if is_group_message and content["ZISFROMME"] == 0: diff --git a/Whatsapp_Chat_Exporter/utility.py b/Whatsapp_Chat_Exporter/utility.py index 589c751..e94303e 100644 --- a/Whatsapp_Chat_Exporter/utility.py +++ b/Whatsapp_Chat_Exporter/utility.py @@ -23,6 +23,7 @@ except ImportError: MAX_SIZE = 4 * 1024 * 1024 # Default 4MB ROW_SIZE = 0x3D0 +CURRENT_TZ_OFFSET = datetime.now().astimezone().utcoffset().seconds / 3600 def convert_time_unit(time_second: int):