mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) New date filter with a calendar view
Summary: Implements the new date filtering panel. Design results from long discussion between: Alex, Anais, Cyprien and Dmitry. Test environment: https://grist-new-date-range-filter.fly.dev/ Test Plan: Include various new tests. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3720
This commit is contained in:
13
app/common/getCurrentTime.ts
Normal file
13
app/common/getCurrentTime.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import moment from "moment-timezone";
|
||||
|
||||
/**
|
||||
* Returns the current local time. Allows overriding via a "currentTime" URL parameter, for the sake
|
||||
* of tests.
|
||||
*/
|
||||
export default function getCurrentTime(): moment.Moment {
|
||||
const getDefault = () => moment();
|
||||
if (typeof window === 'undefined' || !window) { return getDefault(); }
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
|
||||
return searchParams.has('currentTime') ? moment(searchParams.get('currentTime')!) : getDefault();
|
||||
}
|
||||
Reference in New Issue
Block a user