From f9899f6981f8980536b61d3ef25cb6101bdf6cbd Mon Sep 17 00:00:00 2001 From: altoiddealer Date: Sat, 23 Aug 2025 21:31:16 -0400 Subject: [PATCH] Fix datetime placeholders when piped from other nodes --- folder_paths.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/folder_paths.py b/folder_paths.py index b34af39e8..8bc028038 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -1,6 +1,7 @@ from __future__ import annotations import os +import re import time import mimetypes import logging @@ -376,6 +377,21 @@ def get_save_image_path(filename_prefix: str, output_dir: str, image_width=0, im input = input.replace("%hour%", str(now.tm_hour).zfill(2)) input = input.replace("%minute%", str(now.tm_min).zfill(2)) input = input.replace("%second%", str(now.tm_sec).zfill(2)) + + # Handle %date:FORMAT% + def date_repl(match): + fmt = match.group(1) + # Map Java-like formatting to strftime where possible + fmt = (fmt.replace("yyyy", "%Y") + .replace("MM", "%m") + .replace("dd", "%d") + .replace("hh", "%H") + .replace("mm", "%M") + .replace("ss", "%S")) + return time.strftime(fmt, now) + + input = re.sub(r"%date:(.*?)%", date_repl, input) + return input if "%" in filename_prefix: