From faeafa7ab02e82c7b1908f3049e3dddf6cc6ed36 Mon Sep 17 00:00:00 2001 From: lehie Date: Thu, 12 Feb 2026 00:54:16 +0700 Subject: [PATCH] Improve timestamp readability: add dashes, prefix option --- get_timestamp.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/get_timestamp.py b/get_timestamp.py index 964d13a..2e4b3c0 100644 --- a/get_timestamp.py +++ b/get_timestamp.py @@ -8,13 +8,18 @@ class GetTimestamp: def INPUT_TYPES(cls): return { "required": { - "format": (["YYYYMMDD_HHMMSS", "YYYY-MM-DD_HH-MM-SS", "YYYYMMDD", "HHMMSS", "custom"], { - "default": "YYYYMMDD_HHMMSS" + "format": (["YYYY-MM-DD_HH-MM-SS", "YYYYMMDD_HHMMSS", "YYYY-MM-DD", "HH-MM-SS", "custom"], { + "default": "YYYY-MM-DD_HH-MM-SS" }), }, "optional": { + "prefix": ("STRING", { + "default": "", + "multiline": False, + "placeholder": "video_", + }), "custom_format": ("STRING", { - "default": "%Y%m%d_%H%M%S", + "default": "%Y-%m-%d_%H-%M-%S", "multiline": False, }), } @@ -25,23 +30,23 @@ class GetTimestamp: FUNCTION = "get_timestamp" CATEGORY = "comfyui-sortlist" - def get_timestamp(self, format, custom_format="%Y%m%d_%H%M%S"): + def get_timestamp(self, format, prefix="", custom_format="%Y-%m-%d_%H-%M-%S"): now = datetime.now() - if format == "YYYYMMDD_HHMMSS": - result = now.strftime("%Y%m%d_%H%M%S") - elif format == "YYYY-MM-DD_HH-MM-SS": + if format == "YYYY-MM-DD_HH-MM-SS": result = now.strftime("%Y-%m-%d_%H-%M-%S") - elif format == "YYYYMMDD": - result = now.strftime("%Y%m%d") - elif format == "HHMMSS": - result = now.strftime("%H%M%S") + elif format == "YYYYMMDD_HHMMSS": + result = now.strftime("%Y%m%d_%H%M%S") + elif format == "YYYY-MM-DD": + result = now.strftime("%Y-%m-%d") + elif format == "HH-MM-SS": + result = now.strftime("%H-%M-%S") elif format == "custom": result = now.strftime(custom_format) else: - result = now.strftime("%Y%m%d_%H%M%S") + result = now.strftime("%Y-%m-%d_%H-%M-%S") - return (result,) + return (prefix + result,) NODE_CLASS_MAPPINGS = {