@@ -596,27 +596,27 @@ def get_time(incl_time: bool = True, incl_timezone: bool = True) -> str:
596596 y = str (the_time .year )
597597 M = str (the_time .month )
598598 d = str (the_time .day )
599- h = str (the_time .hour )
600- m = str (the_time .minute )
601- s = str (the_time .second )
602599 # putting date parts into one string
603600 if incl_time and incl_timezone :
604- fname = "_" . join ([ y + M + d , h + m + s , timezone ])
601+ fname = the_time . isoformat ( sep = "_" , timespec = "seconds" ) + "_" + timezone
605602 elif incl_time :
606- fname = "_" . join ([ y + M + d , h + m + s ] )
603+ fname = the_time . isoformat ( sep = "_" , timespec = "seconds" )
607604 elif incl_timezone :
608- fname = "_" .join ([y + M + d , timezone ])
605+ fname = "_" .join ([the_time . isoformat ( sep = "_" , timespec = "hours" )[: - 3 ] , timezone ])
609606 else :
610607 fname = y + M + d
611608
609+ # optional
610+ fname = fname .replace (":" , "-" ) # remove ':' from hours, minutes, seconds
612611 # POSTCONDITIONALS
613- parts = fname .split ("_" )
614- if incl_time and incl_timezone :
615- assert len (parts ) == 3 , f"time and/or timezone inclusion issue: { fname } "
616- elif incl_time or incl_timezone :
617- assert len (parts ) == 2 , f"time/timezone inclusion issue: { fname } "
618- else :
619- assert len (parts ) == 1 , f"time/timezone inclusion issue: { fname } "
612+ # ! to delete (was it jused for something?)
613+ # parts = fname.split("_")
614+ # if incl_time and incl_timezone:
615+ # assert len(parts) == 3, f"time and/or timezone inclusion issue: {fname}"
616+ # elif incl_time or incl_timezone:
617+ # assert len(parts) == 2, f"time/timezone inclusion issue: {fname}"
618+ # else:
619+ # assert len(parts) == 1, f"time/timezone inclusion issue: {fname}"
620620
621621 return fname
622622
@@ -641,7 +641,7 @@ def generate_log_filename(folder: str = "logs", suffix: str = "") -> str:
641641 except OSError as e :
642642 raise OSError (f"Error creating directory '{ folder } ': { e } " )
643643 # MAIN FUNCTION
644- log_filename = get_time (incl_timezone = False ) + "_" + suffix + ".log"
644+ log_filename = get_time (incl_timezone = True ) + "_" + suffix + ".log"
645645 log_filepath = os .path .join (folder , log_filename )
646646
647647 return log_filepath
0 commit comments