Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 61x 2578x 2578x 2578x 2578x 2578x 1840x | import { config } from "shared/config";
import { MongoDbError } from "shared/types/api/errors";
import { Result, makeSuccessResult } from "shared/utils/result";
import { findTestSettings } from "server/test/test-settings/testSettingsRepository";
export const getTimeNow = async (): Promise<Result<Date, MongoDbError>> => {
Eif (process.env.SETTINGS !== "production" && config.server().useTestTime) {
const findTestSettingsResult = await findTestSettings();
Iif (!findTestSettingsResult.ok) {
return findTestSettingsResult;
}
const { testTime } = findTestSettingsResult.value;
// An unset mocked time means the real clock, not an unparseable date
return makeSuccessResult(testTime ? new Date(testTime) : new Date());
}
return makeSuccessResult(new Date());
};
|