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

Duration binding helper #1086

Merged
merged 3 commits into from
Feb 4, 2021
Merged

Duration binding helper #1086

merged 3 commits into from
Feb 4, 2021

Conversation

mike12345567
Copy link
Collaborator

Description

Quick addition of a duration helper which can be used to create relative humanized date strings. This comes from a question on Discord where they wanted to recreate the following JS function in Budibase:

var eventTime = '1366549200';
var currentTime = '1366547400';
//Now i am passing the left time from controller itself which handles timezone stuff (UTC), just to simply question i used
//harcoded values.
var leftTime = eventTime - currentTime;
var duration = moment.duration(leftTime, 'seconds');
var interval = 1000;

This helper makes this possible (and arguably easier!) as such:

{{duration ( subtract (date currentTime "X")(date eventTime "X")) "seconds"}}

This was a great use case for making sure the helpers system is very easily extensible - this also uncovered some features that were missing from our main date formatter after the transition from moment -> dayjs (dayjs by default is quite light weight, needs extensions).

Copy link
Member

@shogunpurple shogunpurple left a comment

Choose a reason for hiding this comment

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

Nice - LGTM!

@mike12345567 mike12345567 merged commit b787fc2 into master Feb 4, 2021
@mike12345567 mike12345567 deleted the feature/helper-duration branch February 4, 2021 14:15
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