Add dates for #4575, fiddle with comments for #4578

This commit is contained in:
James Cole
2021-04-02 06:59:55 +02:00
parent 5750087d37
commit 00b0ce6c6e
9 changed files with 108 additions and 53 deletions

View File

@@ -92,13 +92,18 @@ export default {
},
timeStr: {
get() {
// console.log('getTimeStr: ' + this.localTime);
if (this.localTime instanceof Date && !isNaN(this.localTime)) {
return ('0' + this.localTime.getHours()).slice(-2) + ':' + ('0' + this.localTime.getMinutes()).slice(-2) + ':' + ('0' + this.localTime.getSeconds()).slice(-2);
let localStr = ('0' + this.localTime.getHours()).slice(-2) + ':' + ('0' + this.localTime.getMinutes()).slice(-2) + ':' + ('0' + this.localTime.getSeconds()).slice(-2);
// console.log('Time is: ' + localStr);
return localStr;
}
return '';
},
set(value) {
// console.log('Set: ' + value);
if ('' === value) {
// console.log('Value is empty, set 00:00:00');
this.localTime.setHours(0);
this.localTime.setMinutes(0);
this.localTime.setSeconds(0);
@@ -108,9 +113,11 @@ export default {
// bit of a hack but meh.
let current = new Date(this.localTime.getTime());
let parts = value.split(':');
current.setHours(parseInt(parts[0]));
current.setMinutes(parseInt(parts[1]));
current.setSeconds(parseInt(parts[2]));
// console.log('Parts are:');
// console.log(parts);
current.setHours(parseInt(parts[0] ?? 0));
current.setMinutes(parseInt(parts[1] ?? 0));
current.setSeconds(parseInt(parts[2] ?? 0));
this.localTime = current;
this.$emit('set-time', {time: this.localTime});
}