diff --git a/modules/images.py b/modules/images.py index cc5066b1..fb0b373d 100644 --- a/modules/images.py +++ b/modules/images.py @@ -1,4 +1,5 @@ import datetime +import pytz import io import math import os @@ -302,7 +303,7 @@ def apply_filename_pattern(x, p, seed, prompt): x = x.replace("[model_hash]", getattr(p, "sd_model_hash", shared.sd_model.sd_model_hash)) x = x.replace("[date]", datetime.date.today().isoformat()) - x = x.replace("[datetime]", datetime.datetime.now().strftime("%Y%m%d%H%M%S")) + x = replace_datetime(x) x = x.replace("[job_timestamp]", getattr(p, "job_timestamp", shared.state.job_timestamp)) # Apply [prompt] at last. Because it may contain any replacement word.^M @@ -353,6 +354,57 @@ def get_next_sequence_number(path, basename): return result + 1 +def replace_datetime(input_str: str): + """ + Formats sub_string of input_str with formatted datetime with time zone support. + accepts sub_string format: [datetime], [datetime], [datetime