feat: 🎸 added higher resoulution options in the dateTime Filter (#16548)

Title: "feat: Add second, minute & hour resolution options to relative
date Filter action"
---

## Summary

This PR enables support for smaller time units — **Seconds, Minutes, and
Hours** — in the *Relative Date* filter used in workflows, rather than
being limited to days only.

---

## What Changed

This PR extends the relative date filter to include support for the
following units:

✔️ `SECOND`  
✔️ `MINUTE`  
✔️ `HOUR`  
✔️ (Existing: `DAY`, `WEEK`, `MONTH`, etc.)

Changes include:

- Adding `SECOND`, `MINUTE`, and `HOUR` options to the internal relative
date unit enum/constant.
- Updating utility functions and parsers to correctly interpret and
evaluate these new units.
- Enhancing existing tests and adding new tests to cover second, minute,
and hour relative filters.

---

## Testing

New and updated tests include:

- Unit tests for serialization of relative filter values including
seconds, minutes, and hours.
- Workflow filter evaluation tests that verify minute/hour resolution
behaves correctly.

Tests are included in the changeset.

---

## Backward Compatibility

This change is fully backward compatible:

- All existing relative date filters using days or larger units behave
exactly as before.
- Adding finer units does not alter existing stored data or workflow
definitions.

---

##  Issue Reference

Fixes: **twentyhq/twenty#15525**  

<img width="1909" height="896" alt="image"
src="https://github.com/user-attachments/assets/328d03dc-ca0b-4c3f-84e5-58961c178398"
/>

---------

Co-authored-by: Guillim <guillim@users.noreply.github.com>
Co-authored-by: guillim <guigloo@msn.com>
This commit is contained in:
Bhoomaahamso
2025-12-17 22:16:11 +05:30
committed by GitHub
parent 100d4f7f42
commit a560e8ac83
15 changed files with 616 additions and 6 deletions
@@ -491,6 +491,7 @@ export const DateTimePicker = ({
amount={relativeDate?.amount}
unit={relativeDate?.unit ?? 'DAY'}
onChange={onRelativeDateChange}
allowIntraDayUnits={true}
/>
) : (
<DateTimePickerHeader
@@ -1,6 +1,7 @@
import { Select } from '@/ui/input/components/Select';
import { SettingsTextInput } from '@/ui/input/components/SettingsTextInput';
import { RELATIVE_DATE_DIRECTION_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/RelativeDateDirectionSelectOptions';
import { RELATIVE_DATETIME_UNITS_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/RelativeDateTimeUnitSelectOptions';
import { RELATIVE_DATE_UNITS_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/RelativeDateUnitSelectOptions';
import styled from '@emotion/styled';
@@ -30,6 +31,7 @@ type RelativeDatePickerHeaderProps = {
isFormField?: boolean;
readonly?: boolean;
unitDropdownWidth?: number;
allowIntraDayUnits?: boolean;
};
export const RelativeDatePickerHeader = ({
@@ -41,6 +43,7 @@ export const RelativeDatePickerHeader = ({
onChange,
readonly,
unitDropdownWidth,
allowIntraDayUnits,
}: RelativeDatePickerHeaderProps) => {
const amountString = amount?.toString() ?? '';
@@ -50,7 +53,10 @@ export const RelativeDatePickerHeader = ({
const [draftAmountValue, setDraftAmountValue] = useState(amountTextValue);
const isUnitPlural = amount && amount > 1 && direction !== 'THIS';
const unitSelectOptions = RELATIVE_DATE_UNITS_SELECT_OPTIONS.map((unit) => ({
const unitOptionsSource = allowIntraDayUnits
? RELATIVE_DATETIME_UNITS_SELECT_OPTIONS
: RELATIVE_DATE_UNITS_SELECT_OPTIONS;
const unitSelectOptions = unitOptionsSource.map((unit) => ({
...unit,
label: `${unit.label}${isUnitPlural ? 's' : ''}`,
}));
@@ -0,0 +1,15 @@
import { RELATIVE_DATE_UNITS_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/RelativeDateUnitSelectOptions';
import { type RelativeDateFilterUnit } from 'twenty-shared/utils';
type RelativeDateUnitOption = {
value: RelativeDateFilterUnit;
label: string;
};
export const RELATIVE_DATETIME_UNITS_SELECT_OPTIONS: RelativeDateUnitOption[] =
[
...RELATIVE_DATE_UNITS_SELECT_OPTIONS,
{ value: 'HOUR', label: 'Hour' },
{ value: 'MINUTE', label: 'Minute' },
{ value: 'SECOND', label: 'Second' },
];