From f8b04aaf563fe1a7617714d7f5e56df14fee870f Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 6 Nov 2022 14:35:28 +0100 Subject: Add "--datetime-format" option --- package/bin/android-sms-extractor | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'package/bin') diff --git a/package/bin/android-sms-extractor b/package/bin/android-sms-extractor index 601ff8c..f8872ed 100755 --- a/package/bin/android-sms-extractor +++ b/package/bin/android-sms-extractor @@ -32,22 +32,20 @@ parser = ArgumentParser(prog="android-sms-extractor", description="Android SMS Extractor") #=============================================================================== -# Define positional arguments +# Define arguments #=============================================================================== parser.add_argument('db_file', action='store', help="Path to the SQLite database file") +parser.add_argument('--datetime-format', action='store', dest='dt_format', + help="Set datetime (strftime) format for text output (default: %(default)s)", + default="%Y-%m-%d %H:%M:%S") + #=============================================================================== # Parse arguments #=============================================================================== args = parser.parse_args() -# Default -date_format_string = "%Y-%m-%d %H:%M:%S" - -# German version -# date_format_string = "am %d.%m.%Y um %H:%M:%S" - if not os.path.isfile(args.db_file): exit("Could not open file »{}«".format(args.db_file)) @@ -80,7 +78,7 @@ for conversation in c.fetchall(): # Remove the last 3 digits (milliseconds) from timestamp msg_time = int(str(msg_time)[:-3]) - msg_time_formatted = datetime.fromtimestamp(msg_time).strftime(date_format_string) + msg_time_formatted = datetime.fromtimestamp(msg_time).strftime(args.dt_format) sim_slot_id = result[3] -- cgit v1.2.3