gristlabs_grist-core/app/common/getCurrentTime.ts
Cyprien P b7f65ff408 (core) Adds dots menu to access rules page item
Summary: In Access rules page item, adds “…” buttons that shows a menu of users to view-as:

Test Plan: Include new nbrowser test

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3751
2023-01-12 09:40:45 +01:00

14 lines
512 B
TypeScript

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') || undefined) : getDefault();
}