[New] Updated StrolchJS.toLocalDateTime() to only add seconds if parameter set

This commit is contained in:
Robert von Burg 2022-07-11 13:17:48 +02:00
parent 325e4c008b
commit 08e591c315
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
2 changed files with 8 additions and 4 deletions

View File

@ -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) {

View File

@ -1,6 +1,6 @@
{
"name": "strolchjs",
"version": "0.5.2",
"version": "0.5.3",
"main": "Strolch.js",
"ignore": [
"**/.*",