nebular icon indicating copy to clipboard operation
nebular copied to clipboard

nb-timepicker invalid date issue

Open dan0131 opened this issue 3 years ago • 5 comments

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"

dan0131 avatar Jan 05 '22 11:01 dan0131

image

on January month return as 0

dan0131 avatar Jan 06 '22 07:01 dan0131

the same here

vanlecs09 avatar Jan 10 '22 12:01 vanlecs09

@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}; }

dan0131 avatar Jan 11 '22 04:01 dan0131

@katebatura Hi, I have the same issue on Jan 2024, can your fix be merged and backported to a Nebular version 9? Thank you

zhannapopenko avatar Jan 07 '24 08:01 zhannapopenko