You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
512 B
14 lines
512 B
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();
|
|
}
|