Skip to main content

Time Adapter

Use this adapter to get the current server time.

Importing the adapter

To use the Time adapter, import it as shown:
import { timeAdapter } from 'epicenter-libs';

Get server time

The get() function retrieves the current server time.

Permissions

Requires a role of ANONYMOUS or higher.

Function description

  • Constructs a GET request to the /time endpoint.
  • Returns the current server time in ISO 8601 format.
  • If the server responds with 404, the function returns undefined.
Function signature
export async function get(
optionals: RoutingOptions = {},
): Promise<void | string>

Parameters

  • optionals (Type: RoutingOptions):
    • accountShortName? (string) – The account short name. By default, the account associated with the current session is used.
    • projectShortName? (string) – The project short name. By default, the project associated with the current session is used.
    • RoutingOptions – Additional routing options.

Return value

A promise that resolves to:

  • A string representing the current server time in ISO 8601 format, or
  • undefined if the server does not return a value.

Usage example

import { timeAdapter } from 'epicenter-libs';

const serverTime = await timeAdapter.get();