Skip to content

Commit d104b72

Browse files
committed
Fixes silent DatetimePicker error on midnight value
1 parent 2384902 commit d104b72

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/@batch-flask/ui/datetime-picker/datetime-picker.component.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ describe("DatetimePickerComponent", () => {
7272
expect(testComponent.control.value).toEqual(new Date(2017, 11, 14, 17, 32));
7373
});
7474

75+
it("correctly handles midnight", () => {
76+
testComponent.control.setValue(new Date(2022, 3, 15, 0, 0));
77+
expect(timeInputEl.nativeElement.value).toEqual("00:00");
78+
});
79+
7580
it("updates the inputs when setting the date time as a string", () => {
7681
testComponent.control.setValue(new Date(2017, 11, 14, 17, 32).toISOString());
7782
expect(dateInputEl.nativeElement.value).toEqual("12/14/2017");

src/@batch-flask/ui/datetime-picker/datetime-picker.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class DatetimePickerComponent implements ControlValueAccessor, OnDestroy
106106
const datetime = this._getDate(value).setZone(this.currentTimeZone.name);
107107
this.datetime.patchValue({
108108
date: datetime.toJSDate(),
109-
time: `${datetime.hour}:${datetime.minute}`,
109+
time: datetime.toFormat("HH:mm")
110110
});
111111
this.changeDetector.markForCheck();
112112
}

0 commit comments

Comments
 (0)