-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcomfyui_datetime.py
37 lines (28 loc) · 968 Bytes
/
comfyui_datetime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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:%S"}),
}
}
RETURN_TYPES = ("STRING",)
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
# NaN is never equal to itself
return float("NaN")