nebular
nebular copied to clipboard
nb-timepicker invalid date issue
Issue type
I'm submitting a ... (check one with "x")
- [ x] bug report
- [ ] feature request
Issue description
Current behavior:
When I try to change time in nb-timepicker there is an error called InvalidPipeArgument: 'Unable to convert "Invalid Date" into a date' for pipe 'e'
This occurs only when computer date in January. When I change it to February this works fine. If we remove the default value in formBuilder this will work fine.
Expected behavior:
Should able to change time.
Steps to reproduce:
Related code:
html file
<input nbInput id="start-time" type="text" [nbTimepicker]="startTimepicker"
[status]="!jobDetailsFormGroup.controls.startTime.valid ? 'danger' : 'basic'"
formControlName="startTime"
fullWidth (ngModelChange)="setBreakMinMax()"/>
<nb-timepicker twelveHoursFormat="true" #startTimepicker></nb-timepicker>
ts file
this.jobDetailsFormGroup = this.formBuilder.group({
startTime: [new Date(), [Validators.required]]
})
Other information:
npm, node, OS, Browser
Node:v14.15.5, npm: 6.14.11
OS: Windows (10).
Browser: Edge
Angular, Nebular
"@nebular/theme": "7.0.0"
"@angular/cdk": "^11.0.0"

on January month return as 0
the same here
@vanlecs09 for a temporary fix you can override the parseNativeDateString method in NbTimePickerDirective
protected parseNativeDateString(value: string): string { const date = this.dateService.today(); const year = this.dateService.getYear(date); const month = this.calendarTimeModelService.paddToTwoSymbols(this.dateService.getMonth(date)+1); const day = this.calendarTimeModelService.paddToTwoSymbols(this.dateService.getDate(date));
return ${year}-${month}-${day} ${value};
}
@katebatura Hi, I have the same issue on Jan 2024, can your fix be merged and backported to a Nebular version 9? Thank you