Move time constants to time module (#1368)

This commit is contained in:
Charis Kyriakou
2022-05-31 13:21:45 +01:00
committed by GitHub
parent 6b4be93169
commit e417bea948
5 changed files with 11 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ import { DisposableObject } from './pure/disposable-object';
import { workspace, Event, EventEmitter, ConfigurationChangeEvent, ConfigurationTarget } from 'vscode'; import { workspace, Event, EventEmitter, ConfigurationChangeEvent, ConfigurationTarget } from 'vscode';
import { DistributionManager } from './distribution'; import { DistributionManager } from './distribution';
import { logger } from './logging'; import { logger } from './logging';
import { ONE_DAY_IN_MS } from './pure/helpers-pure'; import { ONE_DAY_IN_MS } from './pure/time';
/** Helper class to look up a labelled (and possibly nested) setting. */ /** Helper class to look up a labelled (and possibly nested) setting. */
export class Setting { export class Setting {

View File

@@ -31,11 +31,6 @@ export const asyncFilter = async function <T>(arr: T[], predicate: (arg0: T) =>
return arr.filter((_, index) => results[index]); return arr.filter((_, index) => results[index]);
}; };
export const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
export const ONE_HOUR_IN_MS = 1000 * 60 * 60;
export const TWO_HOURS_IN_MS = 1000 * 60 * 60 * 2;
export const THREE_HOURS_IN_MS = 1000 * 60 * 60 * 3;
/** /**
* This regex matches strings of the form `owner/repo` where: * This regex matches strings of the form `owner/repo` where:
* - `owner` is made up of alphanumeric characters or single hyphens, starting and ending in an alphanumeric character * - `owner` is made up of alphanumeric characters or single hyphens, starting and ending in an alphanumeric character

View File

@@ -1,7 +1,11 @@
/* /*
* Contains an assortment of helper functions for working with time, dates, and durations. * Contains an assortment of helper constants and functions for working with time, dates, and durations.
*/ */
export const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
export const ONE_HOUR_IN_MS = 1000 * 60 * 60;
export const TWO_HOURS_IN_MS = 1000 * 60 * 60 * 2;
export const THREE_HOURS_IN_MS = 1000 * 60 * 60 * 3;
const durationFormatter = new Intl.RelativeTimeFormat('en', { const durationFormatter = new Intl.RelativeTimeFormat('en', {
numeric: 'auto', numeric: 'auto',

View File

@@ -28,7 +28,8 @@ import { URLSearchParams } from 'url';
import { QueryServerClient } from './queryserver-client'; import { QueryServerClient } from './queryserver-client';
import { DisposableObject } from './pure/disposable-object'; import { DisposableObject } from './pure/disposable-object';
import { commandRunner } from './commandRunner'; import { commandRunner } from './commandRunner';
import { assertNever, ONE_HOUR_IN_MS, TWO_HOURS_IN_MS, getErrorMessage, getErrorStack } from './pure/helpers-pure'; import { ONE_HOUR_IN_MS, TWO_HOURS_IN_MS } from './pure/time';
import { assertNever, getErrorMessage, getErrorStack } from './pure/helpers-pure';
import { CompletedLocalQueryInfo, LocalQueryInfo as LocalQueryInfo, QueryHistoryInfo } from './query-results'; import { CompletedLocalQueryInfo, LocalQueryInfo as LocalQueryInfo, QueryHistoryInfo } from './query-results';
import { DatabaseManager } from './databases'; import { DatabaseManager } from './databases';
import { registerQueryHistoryScubber } from './query-history-scrubber'; import { registerQueryHistoryScubber } from './query-history-scrubber';

View File

@@ -14,7 +14,7 @@ import { QueryServerClient } from '../../queryserver-client';
import { LocalQueryInfo, InitialQueryInfo } from '../../query-results'; import { LocalQueryInfo, InitialQueryInfo } from '../../query-results';
import { DatabaseManager } from '../../databases'; import { DatabaseManager } from '../../databases';
import * as tmp from 'tmp-promise'; import * as tmp from 'tmp-promise';
import { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, TWO_HOURS_IN_MS, THREE_HOURS_IN_MS } from '../../pure/helpers-pure'; import { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, TWO_HOURS_IN_MS, THREE_HOURS_IN_MS } from '../../pure/time';
import { tmpDir } from '../../helpers'; import { tmpDir } from '../../helpers';
import { getErrorMessage } from '../../pure/helpers-pure'; import { getErrorMessage } from '../../pure/helpers-pure';
import { HistoryItemLabelProvider } from '../../history-item-label-provider'; import { HistoryItemLabelProvider } from '../../history-item-label-provider';