2 Commits
Author SHA1 Message Date
Tsering Paljor 472e877d79 feat: Improve duration support in advanced formulas (#5426)
* Refactor to_duration() to accept an optional format arg.

* Add tests for duration utils

* Add tests for new DurationFormation* arg type

* Expand tests for RuntimeToDuration

* Add duration_format()

* Add tests for RuntimeDurationFormat

* Add a Utility formula category, and recategorize some functions

* Allow formula validation visitor allows validating deferred args.

* Improve test coverage

* Add changelog

* Fix frontend test failure

* Remove changes around deferred arg validation

* Clean up stale logic

* Fix docstring

* Ensure tokenize_duration_format/tokenizeDurationFormat supports fractional seconds.

* Use rounding instead of truncating for fractional precision to match the existing format_duration_value()

* Add missing test coverage for duration field formatting.

* Add support to tokenizer to escape tokens.

* format_duration_value/formatDurationFalue is now just a shim that wraps a call to the unified formatValueWithDurationFormat.

* Fix to_duration() example.
2026-06-15 15:09:34 +07:00
Tsering PaljorandJeremie Pardou 87fbf1f2bb feat: Add Runtime Formula for formatting numbers (#5262)
* Add new skill for creating/updating runtime formulas.

* Add abs() formula function

* Add getErrorMessage() to arg type to return a human-readable error message.

* Update skill to ensure getErrorMessage() is overridden when appropriate.

* Add null() runtime formula.

* Add number_format() runtime formula.

* Fix tests

* Add changelog entry

* Add date_interval() runtime formula.

* Fix test

* Add runtime formula: to_datetime()

* Update changelog

* Fix backend test

* Fix frontend test

* Add new ensure_date_interval() ensurer.

* Update descriptions and examples.

* Remove references to Moment.js

* Refactor validate_type_of_args() to return the index of the invalid arg.

* Refactor to_datetime() to use ensure_datetime()

* Use ensure_date_interval ensurer for IntervalStringBaserowRuntimeFormulaArgumentType

* Update skill with sections on ensurers.

* Add optional strict arg to ensure_datetime()

* Fix tests

* Simplify the ensure_string() to return total seconds for timedelta.

* ensure_date_interval() should also try to convert numbers to a timedelta.

* Fix test

* Use ensure_integer() in ensure_date_interval()

* Rename DateInterval to Duration

* Return an array of all possible errors.

* Use database duration parser for consistency

* Remove contrib references in core.

* Add additional test coverage

* Rename duration to to_duration

* Attempt to fix CI

* Reverting some changes

* Ensure empty string '' isn't accepted as a datetime format.

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-05-26 14:47:13 +07:00