From 457c06d470cd0b2519a9e30765c52a78a119e335 Mon Sep 17 00:00:00 2001 From: Tau Date: Mon, 29 Apr 2019 17:25:50 -0400 Subject: [PATCH] Add adjustments for UTC time sent to clients --- src/startup.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/startup.ts b/src/startup.ts index 136ca8f..114625b 100644 --- a/src/startup.ts +++ b/src/startup.ts @@ -1,3 +1,4 @@ +import addHours = require("date-fns/add_hours"); import express = require("express"); import iconv = require("iconv-lite"); import read = require("raw-body"); @@ -6,6 +7,7 @@ import { unzipSync } from "zlib"; import { hostname } from "./hostname"; +const hourDelta = parseInt(process.env.HOUR_DELTA || "0"); const myHost = hostname(); const uris = new Map(); @@ -72,7 +74,8 @@ app.post("/sys/servlet/PowerOn", function(req, resp) { // Cut milliseconds out of ISO timestamp const now = new Date(); - const isoStrWithMs = now.toISOString(); + const adjusted = addHours(now, -hourDelta); + const isoStrWithMs = adjusted.toISOString(); const isoStr = isoStrWithMs.substr(0, 19) + "Z"; const resParams = {