From a5ca9cdacaad05e80a5d4c0f8d073a7c96a51f25 Mon Sep 17 00:00:00 2001 From: randomnerd Date: Thu, 17 Sep 2020 11:28:00 +0300 Subject: [PATCH 1/3] change time source in config to http://worldtimeapi.org/api/timezone/Etc/UTC --- src/oracle.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/oracle.ts b/src/oracle.ts index 724ca23..c7617d0 100755 --- a/src/oracle.ts +++ b/src/oracle.ts @@ -166,9 +166,7 @@ export class Oracle { public async getTime(): Promise { const res = await fetch(this.clockApi); const time = await res.json(); - const date = new Date(time.currentDateTime.replace('Z', ':00.000')); - this.timeOffset = date.getTimezoneOffset() * 60000; - return date.getTime() - this.timeOffset; + return new Date(time.utc_datetime).getTime(); } From b5fc6a3ababb9cae3cec0d902d166bef6ae3ddff Mon Sep 17 00:00:00 2001 From: randomnerd Date: Thu, 17 Sep 2020 11:30:32 +0300 Subject: [PATCH 2/3] config example --- conf.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.json.example b/conf.json.example index c722581..538572e 100755 --- a/conf.json.example +++ b/conf.json.example @@ -9,5 +9,5 @@ "ethContractAddress": "0x8895345ad1c1a2bff799a575f83d89669ba4bce3", "Contract": "eosio.bridge", "blocksBehind": 0, - "clockApi": "http://worldclockapi.com/api/json/utc/now" + "clockApi": "http://worldtimeapi.org/api/timezone/Etc/UTC" } From 6b39f70ae527bc87118115fb444272d43a21bd46 Mon Sep 17 00:00:00 2001 From: randomnerd Date: Thu, 17 Sep 2020 13:24:15 +0300 Subject: [PATCH 3/3] return clock offset --- src/oracle.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/oracle.ts b/src/oracle.ts index c7617d0..ad5924f 100755 --- a/src/oracle.ts +++ b/src/oracle.ts @@ -166,7 +166,9 @@ export class Oracle { public async getTime(): Promise { const res = await fetch(this.clockApi); const time = await res.json(); - return new Date(time.utc_datetime).getTime(); + const date = new Date(time.utc_datetime); + this.timeOffset = date.getTimezoneOffset() * 60000; + return date.getTime() - this.timeOffset; }