new JWDatetimeString node
This commit is contained in:
@@ -11,6 +11,7 @@ NODE_MODULES = [
|
||||
".comfyui_raft",
|
||||
".comfyui_image_channel_ops",
|
||||
".comfyui_color_ops",
|
||||
".comfyui_datetime",
|
||||
]
|
||||
|
||||
# Extra nodes for my own use
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
from datetime import datetime
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
|
||||
|
||||
def register_node(identifier: str, display_name: str):
|
||||
def decorator(cls):
|
||||
NODE_CLASS_MAPPINGS[identifier] = cls
|
||||
NODE_DISPLAY_NAME_MAPPINGS[identifier] = display_name
|
||||
|
||||
return cls
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
@register_node("JWDatetimeString", "Datetime String")
|
||||
class _:
|
||||
CATEGORY = "jamesWalker55"
|
||||
|
||||
INPUT_TYPES = lambda: {
|
||||
"required": {
|
||||
"format": ("STRING", {"default": "%Y-%m-%dT%H:%M:%SZ"}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_NAMES = ("STRING",)
|
||||
RETURN_TYPES = ("STRING",)
|
||||
|
||||
OUTPUT_NODE = False
|
||||
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(self, format: str):
|
||||
now = datetime.now()
|
||||
return (now.strftime(format),)
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *args):
|
||||
# This value will be compared with previous 'IS_CHANGED' outputs
|
||||
# If inequal, then this node will be considered as modified
|
||||
return object()
|
||||
Reference in New Issue
Block a user