Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Time Expression Functions #2880

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

thedist
Copy link
Member

@thedist thedist commented May 24, 2024

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.

@krocheck krocheck requested a review from Julusian May 28, 2024 16:50
Copy link
Member

@Julusian Julusian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read t

@thedist thedist marked this pull request as ready for review June 20, 2024 19:12
@Julusian Julusian changed the title Feat: Time Expression Functions feat: Time Expression Functions Jun 27, 2024
@Julusian Julusian merged commit b5ad56d into bitfocus:main Jun 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants