From a86a0adc56b2056a807faec0012ba3b56503b118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6lbel?= Date: Wed, 3 May 2017 18:50:38 +0200 Subject: [PATCH] use timezoneoffset to determine the timezone --- .../token/controllers/tokenDetailController.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/privacyidea/static/components/token/controllers/tokenDetailController.js b/privacyidea/static/components/token/controllers/tokenDetailController.js index b74e3ce22d..a2b1fd7e17 100644 --- a/privacyidea/static/components/token/controllers/tokenDetailController.js +++ b/privacyidea/static/components/token/controllers/tokenDetailController.js @@ -11,9 +11,19 @@ function date_object_to_string(date_obj) { h = (h>9 ? '' : '0') + h; var m = date_obj.getMinutes(); m = (m>9 ? '' : '0') + m; - var o = date_obj.toTimeString().split(" ")[1]; - // 10:20:11 GMT+0200 (CEST) - o = o.substring(3); + + var tz = date_obj.getTimezoneOffset(); + var tz_abs = Math.abs(tz); + var hours = Math.floor(tz_abs/60); + hours = (hours>9 ? '': '0') + hours; + var minutes = tz_abs % 60; + minutes = (minutes>9 ? '': '0') + minutes; + var sign = "-"; + if (tz < 0) { + // The offset for +0100 is -60! + sign = "+"; + } + var o = sign + hours + minutes; s = Y + "-" + M + "-" + D + "T" + h + ":" + m + o; } return s;