Skip to content

Commit

Permalink
[New] Updated StrolchJS.toLocalDateTime() to only add seconds if para…
Browse files Browse the repository at this point in the history
…meter set
  • Loading branch information
eitch committed Jul 11, 2022
1 parent 325e4c0 commit 08e591c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions Strolch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strolchjs",
"version": "0.5.2",
"version": "0.5.3",
"main": "Strolch.js",
"ignore": [
"**/.*",
Expand Down

0 comments on commit 08e591c

Please sign in to comment.