From 459851132e13235acfa7aa3250f07bc57d26bd78 Mon Sep 17 00:00:00 2001 From: Pauan Date: Wed, 14 Jan 2026 00:53:37 +0100 Subject: [PATCH 1/3] Add Time Now (UTC) node --- src/basic_data_handling/time_nodes.py | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/basic_data_handling/time_nodes.py b/src/basic_data_handling/time_nodes.py index 78c2bf5..b8e896e 100644 --- a/src/basic_data_handling/time_nodes.py +++ b/src/basic_data_handling/time_nodes.py @@ -52,6 +52,38 @@ def get_now(self, trigger=None) -> tuple[datetime.datetime]: return (datetime.datetime.now(),) +class TimeNowUTC(ComfyNodeABC): + """ + Returns the current time and date as a DATETIME object, in the UTC timezone. + Note: Output changes for every run, providing a fresh timestamp each time. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "optional": { + "trigger": (IO.ANY, {"description": "Optional input to trigger execution"}) + } + } + + RETURN_TYPES = (IO.DATETIME,) + RETURN_NAMES = ("now",) + CATEGORY = "Basic/time" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "get_now_utc" + + @classmethod + def IS_CHANGED(s, **kwargs): + # Always return a changing value to indicate the output changes every run + return time.time() + + def get_now_utc(self, trigger=None) -> tuple[datetime.datetime]: + """ + Retrieves the current system time in the UTC timezone. + The optional trigger input can be used to trigger execution. + """ + return (datetime.datetime.now(datetime.UTC),) + + class TimeToUnix(ComfyNodeABC): """ Converts a DATETIME object to a Unix timestamp (a float representing seconds since the epoch). @@ -287,6 +319,7 @@ def extract(self, datetime: datetime.datetime) -> tuple[int, int, int, int, int, NODE_CLASS_MAPPINGS = { "Basic data handling: TimeNow": TimeNow, + "Basic data handling: TimeNowUTC": TimeNowUTC, "Basic data handling: TimeToUnix": TimeToUnix, "Basic data handling: UnixToTime": UnixToTime, "Basic data handling: TimeFormat": TimeFormat, @@ -300,6 +333,7 @@ def extract(self, datetime: datetime.datetime) -> tuple[int, int, int, int, int, NODE_DISPLAY_NAME_MAPPINGS = { "Basic data handling: TimeNow": "Time Now", + "Basic data handling: TimeNowUTC": "Time Now (UTC)", "Basic data handling: TimeToUnix": "Time to Unix Timestamp", "Basic data handling: UnixToTime": "Unix Timestamp to Time", "Basic data handling: TimeFormat": "Format Time String", From 97e9d1579538644e695f46fd05ba644f3bcfa417 Mon Sep 17 00:00:00 2001 From: Pauan Date: Wed, 14 Jan 2026 00:55:34 +0100 Subject: [PATCH 2/3] Adding in test for Time Now (UTC) node --- tests/test_time_nodes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_time_nodes.py b/tests/test_time_nodes.py index a810a17..63c14ae 100644 --- a/tests/test_time_nodes.py +++ b/tests/test_time_nodes.py @@ -3,6 +3,7 @@ from datetime import datetime, timedelta from src.basic_data_handling.time_nodes import ( TimeNow, + TimeNowUTC, TimeToUnix, UnixToTime, TimeFormat, @@ -27,6 +28,19 @@ def test_time_now(): assert len(result_with_trigger) == 1 assert isinstance(result_with_trigger[0], datetime) +def test_time_now_utc(): + node = TimeNowUTC() + result = node.get_now_utc() + assert isinstance(result, tuple) + assert len(result) == 1 + assert isinstance(result[0], datetime) + + # Test with trigger parameter + result_with_trigger = node.get_now_utc(trigger="any value") + assert isinstance(result_with_trigger, tuple) + assert len(result_with_trigger) == 1 + assert isinstance(result_with_trigger[0], datetime) + def test_time_to_unix(): node = TimeToUnix() test_datetime = datetime(2023, 1, 1, 12, 0, 0) From ebce83f259837cc9c25d49a8335b6a68b5f35a58 Mon Sep 17 00:00:00 2001 From: Pauan Date: Wed, 14 Jan 2026 00:56:33 +0100 Subject: [PATCH 3/3] Adding TimeNowUTC to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb05c02..6f524b7 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ String manipulation nodes: Date and time manipulation nodes: -- **DateTime creation/conversion**: TimeNow, TimeToUnix, UnixToTime +- **DateTime creation/conversion**: TimeNow, TimeNowUTC, TimeToUnix, UnixToTime - **String formatting/parsing**: TimeFormat, TimeParse - **Time calculations**: TimeDelta, TimeAddDelta, TimeSubtractDelta, TimeDifference - **Component extraction**: TimeExtract (year, month, day, hour, etc.)