diff --git a/public/controllers/agent/agents.js b/public/controllers/agent/agents.js index c0be0b09bc..9e003f1479 100644 --- a/public/controllers/agent/agents.js +++ b/public/controllers/agent/agents.js @@ -920,7 +920,7 @@ export class AgentsController { try { return text + this.timeService.offset(time); } catch (error) { - return `${text}${time} (UTC)`; + return time !== '-' ? `${text}${time} (UTC)` : time; } } diff --git a/public/controllers/misc/reporting.js b/public/controllers/misc/reporting.js index 9294234957..cd38aa68db 100644 --- a/public/controllers/misc/reporting.js +++ b/public/controllers/misc/reporting.js @@ -51,7 +51,7 @@ export class ReportingController { try { return this.timeService.offset(time); } catch (error) { - return `${time} (UTC)`; + return time !== '-' ? `${time} (UTC)` : time; } } diff --git a/public/services/time-service.js b/public/services/time-service.js index c1a62ad3c9..aebcae681a 100644 --- a/public/services/time-service.js +++ b/public/services/time-service.js @@ -17,7 +17,10 @@ export class TimeService { */ offset(d) { try { - const date = new Date(d.replace('Z', '')); + const [day, time] = d.indexOf('T') !== -1 ? d.split('T') : d.split(' '); + const [year, month, monthDay] = d.indexOf('-') !== -1 ? day.split('-') : day.split('/'); + const [hour, minute, seconds] = time.split(':'); + const date = new Date(year, parseInt(month) - 1, monthDay, hour, minute, seconds.split('.')[0]); const offset = new Date().getTimezoneOffset(); const offsetTime = new Date(date.getTime() - offset * 60000); return offsetTime.toLocaleString('en-ZA').replace(',', '');