From 55266b625e046e226e5a92b474b6c8e057b23630 Mon Sep 17 00:00:00 2001 From: peepopoggers <72892531+peepopoggers@users.noreply.github.com> Date: Thu, 28 Jan 2021 23:40:16 +0000 Subject: [PATCH] Added time function from inverse --- src/shared-endpoints.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/shared-endpoints.ts b/src/shared-endpoints.ts index d70d92a..b7bae2d 100644 --- a/src/shared-endpoints.ts +++ b/src/shared-endpoints.ts @@ -132,4 +132,12 @@ export default class SharedEndpoints { getApiAnnouncements(): GenericAPIResponse { return this.requestWrapper.get('v2/public/announcement'); } + + async getTimeOffset(): Promise { + const start = Date.now(); + return this.getServerTime().then(result => { + const end = Date.now(); + return Math.ceil((result.time_now * 1000) - end + ((end - start) / 2)); + }); + } }