Skip to content

Commit

Permalink
simplepicker: Update the time based on the reset date.
Browse files Browse the repository at this point in the history
We update the date but not the time before. This commit fixes this.
  • Loading branch information
priyank-p committed May 28, 2020
1 parent 29e9fad commit e4d3499
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SimplePicker {
private $date: HTMLElement;
private $day: HTMLElement;
private $time: HTMLElement;
private $timeInput: HTMLElement;
private $timeInput: HTMLInputElement;
private $timeSectionIcon: HTMLElement;
private $cancel: HTMLElement;
private $ok: HTMLElement;
Expand Down Expand Up @@ -137,6 +137,13 @@ class SimplePicker {
this.selectDateElement($dateEl);
this.updateDateComponents(date);
}

// The timeFull variable below will be formatted as HH:mm:ss.
// Using regular experssion we remove the :ss parts.
const timeFull = date.toTimeString().split(" ")[0]
const time = timeFull.replace(/\:\d\d$/, "");
this.$timeInput.value = time;
this.$time.innerText = dateUtil.formatTimeFromInputElement(time);
}

compactMode() {
Expand Down

0 comments on commit e4d3499

Please sign in to comment.