(core) Fix date filter for DateTime columns.

Summary:
Date filter was not taking timezone correclty into account, which was
causing to wrong-inclusion and wrong-exclusion of dates near the
bounds.

Diff fixes that, it also bring little refactoring that hopefully clarifies things a little.

Test Plan: Includes brand new test for `app/common/ColumnFilterFunc`.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3763
This commit is contained in:
Cyprien P
2023-01-17 12:05:22 +01:00
parent a822a5771c
commit 18d016c745
6 changed files with 99 additions and 55 deletions

View File

@@ -1,5 +1,11 @@
import {
CURRENT_DATE, diffUnit, formatRelBounds, IPeriod, IRelativeDateSpec, isEquivalentRelativeDate, toUnixTimestamp
CURRENT_DATE,
diffUnit,
formatRelBounds,
IPeriod,
IRelativeDateSpec,
isEquivalentRelativeDate,
relativeDateToUnixTimestamp
} from "app/common/RelativeDates";
import { IRangeBoundType, isRelativeBound } from "app/common/FilterState";
import getCurrentTime from "app/common/getCurrentTime";
@@ -55,7 +61,7 @@ function relativeDateOptionsSpec(value: IRangeBoundType): Array<IRangeBoundType>
if (value === undefined) {
return DEFAULT_OPTION_LIST;
} else if (isRelativeBound(value)) {
value = toUnixTimestamp(value);
value = relativeDateToUnixTimestamp(value);
}
const date = moment.utc(value * 1000);