bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Streamdeck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.46k stars 489 forks source link

feat: Time Expression Functions #2880

Closed thedist closed 1 day ago

thedist commented 1 month ago

Adds timeOffset and timeDiff Expression functions, as well as change the Expression Function documentation to create a Time operations section to group up these, and the previous time related functions.

timeOffset allows taking in a timestamp an offset, and optionally a 12 hour clock boolean, and outputting the time with that offset in the same format it came in with (eg, if hh:mm:ss is provided, then hh:mm:ss is returned, if seconds are omitted then likewise in the return value).

timeDiff compares 2 times, either in hh:mm:ss style format, or a Date Time String, eg YYYY-MM-DDTHH:mm:ss.sssZ, with the return value in seconds. This allows for easy creation of countdowns, formatting of the seconds can easily be done with the existing msToTimestamp Expression Function, and because the return value is a number it also makes it easy to do things like triggers when the value is less than 30 seconds, or when it becomes negative to show when over-running etc....

These sort of basic time functions should help with the growing use of Expression Funcitons and Triggers for more complex automation. I had considered an additional function that would allow a timezone instead of an offset, but with the frequent confusion around time zones due to DST (eg, people referring to EST instead of EDT, or GMT instead of BST) using a numerical or timestamp offset in timeOffset should be a more reliable option.