Create Time Delta
A Duration You Can Add, Subtract, and Measure With
- TIMEDELTA
A point in time and a duration are different things, and this pack treats them differently. Create Time Delta builds the duration - a TIMEDELTA object representing something like "3 days and 4 hours" - that you then add to or subtract from DATETIME values with the pack's TimeAddDelta and TimeSubtractDelta nodes. It's the "how much" that makes the "when" arithmetic possible.
How it works
From StableLlama's Basic data handling pack - Python's datetime.timedelta() in a node. All seven inputs are optional, each a FLOAT defaulting to 0:
days,seconds,microsecondsmilliseconds,minutes,hours,weeks
That's the entire API. You set whichever units describe your duration and the node assembles them into one TIMEDELTA. Mix freely - days=2, hours=3 gives you a single 2-day-3-hour duration, not two separate objects. Fractional values work too, so hours=1.5 is an hour and a half.
Output: one TIMEDELTA object. As with the pack's DATETIME type, TIMEDELTA is custom - it only connects to this pack's nodes, which are precisely the ones that know what to do with it: TimeAddDelta, TimeSubtractDelta, and TimeDifference (which produces timedeltas).
Why you'd build one
The whole time-arithmetic corner of this pack is about answering "what time is it relative to something else":
- "Retry" or "expiry" logic - take now, add a delta of 1 hour, and you have a deadline.
- Scheduling windows - now minus 7 days gives you "a week ago" for cleanup or comparison.
- Offsetting parsed dates - parse a date from a filename, add 30 days, format the result as a new filename.
The standard chain is Time Delta → Time Add/Subtract Delta → Time Format, turning "now plus three days" into a concrete timestamp string.
Installing it
Search "Basic data handling" in ComfyUI Manager and restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart and it's live. No dependencies, no models - pure Python.
Gotchas
Two easy stumbles. First, the output is a TIMEDELTA, not a DATETIME - you can't wire it straight into a text or TimeFormat input; you have to add/subtract it to a DATETIME first, or it won't connect. Second, all the units are positive-or-zero by default - there's no negative sign field, so for "go back in time" you subtract the delta rather than making it negative. days=-1 works in the input, but the idiomatic pattern is a positive delta and TimeSubtractDelta.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| daysopt | FLOAT | 0.00 | — |
| secondsopt | FLOAT | 0.00 | — |
| microsecondsopt | FLOAT | 0.00 | — |
| millisecondsopt | FLOAT | 0.00 | — |
| minutesopt | FLOAT | 0.00 | — |
| hoursopt | FLOAT | 0.00 | — |
| weeksopt | FLOAT | 0.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TIMEDELTA | TIMEDELTA | — |