mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -3,7 +3,7 @@ import {CellValue} from 'app/common/DocActions';
|
||||
import {
|
||||
FilterSpec, FilterState, IRelativeDateSpec, isRangeFilter, isRelativeBound, makeFilterState
|
||||
} from "app/common/FilterState";
|
||||
import {toUnixTimestamp} from "app/common/RelativeDates";
|
||||
import {relativeDateToUnixTimestamp} from "app/common/RelativeDates";
|
||||
import {nativeCompare} from 'app/common/gutil';
|
||||
import {Computed, Disposable, Observable} from 'grainjs';
|
||||
|
||||
@@ -124,9 +124,11 @@ export class ColumnFilter extends Disposable {
|
||||
return this.makeFilterJson() !== this._initialFilterJson;
|
||||
}
|
||||
|
||||
public getBoundsValue(minMax: 'min' | 'max'): number | undefined {
|
||||
// Retuns min or max as a numeric value.
|
||||
public getBoundsValue(minMax: 'min' | 'max'): number {
|
||||
const value = this[minMax].get();
|
||||
return isRelativeBound(value) ? toUnixTimestamp(value) : value;
|
||||
if (value === undefined) { return minMax === 'min' ? -Infinity : +Infinity; }
|
||||
return isRelativeBound(value) ? relativeDateToUnixTimestamp(value) : value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user