Fix datetime placeholders when piped from other nodes #9523
+16
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #9503
Currently:
%date:FORMAT%
placeholders in fields likefilename_prefix
are only expanded when entered directly in the node UI. This works because the frontend handles the substitution before passing the value to the backend.However, if the same string is piped in from another node (e.g. String, Combine Text, etc.), the placeholder is passed to the backend unchanged. Since the backend’s compute_vars function only supports a fixed set of tokens (%year%, %month%, %day%, etc.), %date:...% values are not resolved. This leads to incorrect or invalid filenames such as:
yyyy-MM-ddhhmmss_00001.png
or, on Windows, runtime errors like:
OSError: [Errno 22] Invalid argument: '...\\%date:yyyy-MM-dd%_%date:hhmmss%__00001.png'
Fix
This PR adds backend support for %date:FORMAT%.
Introduces a regex-based handler for %date:...%
Maps common Java/ISO-style patterns (yyyy, MM, dd, hh, mm, ss) to Python’s strftime equivalents
Ensures consistent substitution regardless of the source of the format string
Result
With this change, both direct inputs and piped inputs produce correctly formatted filenames. For example:
Input:
WAN/%date:yyyy-MM-dd%%date:hhmmss%
Output:
WAN/2025-08-23_143752_00001.png
This makes datetime substitution consistent across all nodes and prevents invalid filenames.