mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
30600c5dc2
Summary: By default the fallback contains the prefix, which doesn't work well with a key based translations. Now makeT helper will fallback to the passed key (without a prefix). Test Plan: Added new client test Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3758
14 lines
500 B
TypeScript
14 lines
500 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')!) : getDefault();
|
|
}
|