summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/TimeService.ts
blob: 59c3d4c12b83d8222daed9044ad235070fcca65a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { Injectable } from '@nestjs/common';

/**
 * Provides abstractions to access the current time.
 * Exists for unit testing purposes, so that tests can "simulate" any given time for consistency.
 */
@Injectable()
export class TimeService {
	/**
	 * Returns Date.now()
	 */
	public get now() {
		return Date.now();
	}

	/**
	 * Returns a new Date instance.
	 */
	public get date() {
		return new Date();
	}
}