Fix automatic date/time setting on transaction edit/creation

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2020-02-27 15:50:40 +00:00
parent 6aa76d6743
commit 89e75b2ff8

View file

@ -35,8 +35,8 @@ export class AddEditTransactionComponent implements OnInit, OnChanges {
} else {
d = new Date();
}
this.transactionDate = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
this.currentTime = `${d.getHours()}:${d.getMinutes()}`;
this.transactionDate = d.toLocaleDateString(undefined, {year: 'numeric', month: '2-digit', day: '2-digit'});
this.currentTime = d.toLocaleTimeString(undefined, {hour: '2-digit', hour12: false, minute: '2-digit'});
}
ngOnChanges(changes: SimpleChanges) {
@ -45,8 +45,8 @@ export class AddEditTransactionComponent implements OnInit, OnChanges {
}
const d = new Date(changes.currentTransaction.currentValue.date * 1000);
this.transactionDate = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
this.currentTime = `${d.getHours()}:${d.getMinutes()}`;
this.transactionDate = d.toLocaleDateString(undefined, {year: 'numeric', month: '2-digit', day: '2-digit'});
this.currentTime = d.toLocaleTimeString(undefined, {hour: '2-digit', hour12: false, minute: '2-digit'});
}
save(): void {