From 1811a52dec9eb729ba0b0b2d137e8f1d190110ab Mon Sep 17 00:00:00 2001 From: Brian Read Date: Mon, 16 Sep 2024 18:32:22 +0100 Subject: [PATCH] Add in def to check if an existing file modified and then generatename plus new --- sm2gen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sm2gen.py b/sm2gen.py index 44691e0..1976023 100644 --- a/sm2gen.py +++ b/sm2gen.py @@ -314,11 +314,11 @@ def check_file_version(filename): # Convert the string timestamp to a datetime object file_timestamp = datetime.strptime(timestamp_str, '%Y-%m-%d %H:%M:%S') - # Get the last modified time of the file - file_modified_time = datetime.fromtimestamp(os.path.getmtime(filename)) + # Get the last modified time of the file, ignoring milliseconds + file_modified_time = datetime.fromtimestamp(os.path.getmtime(filename)).replace(microsecond=0) # Compare the timestamps - if file_modified_time > file_timestamp: + if file_modified_time > (file_timestamp): return f"{filename}.new" else: return filename