From 08e591c3152ae66d3189366b721b9be060ca5da9 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 11 Jul 2022 13:17:48 +0200 Subject: [PATCH] [New] Updated StrolchJS.toLocalDateTime() to only add seconds if parameter set --- Strolch.js | 10 +++++++--- bower.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Strolch.js b/Strolch.js index 4c03c4e..e10d27d 100644 --- a/Strolch.js +++ b/Strolch.js @@ -478,11 +478,15 @@ Strolch = { return date.toLocaleDateString('de-CH') }, - toLocalDateTime: function (val) { + toLocalDateTime: function (val, withSeconds) { if (this.isEmptyString(val) || val === '-') return '-'; var date = new Date(val); - if (this.props.locale != null) return date.toLocaleDateString(this.props.locale) + ' ' + date.toLocaleTimeString(this.props.locale); - return date.toLocaleDateString('de-CH') + ' ' + date.toLocaleTimeString('de-CH'); + var locale = this.props.locale != null ? this.props.locale : "de-CH"; + if (withSeconds) { + return date.toLocaleDateString(locale) + ' ' + date.toLocaleTimeString(locale); + } else { + return date.toLocaleDateString(locale) + ' ' + this.getTimeString(date); + } }, toDateTime: function (val) { diff --git a/bower.json b/bower.json index eedcd1a..f64ec09 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "strolchjs", - "version": "0.5.2", + "version": "0.5.3", "main": "Strolch.js", "ignore": [ "**/.*",