Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nb-timepicker invalid date issue #2995

Open
1 task
dan0131 opened this issue Jan 5, 2022 · 4 comments · May be fixed by #3004
Open
1 task

nb-timepicker invalid date issue #2995

dan0131 opened this issue Jan 5, 2022 · 4 comments · May be fixed by #3004
Assignees
Projects

Comments

@dan0131
Copy link

dan0131 commented Jan 5, 2022

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
Copy link
Author

dan0131 commented Jan 6, 2022

image

on January month return as 0

@vanlecs09
Copy link

the same here

@dan0131
Copy link
Author

dan0131 commented Jan 11, 2022

@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 katebatura self-assigned this Jan 12, 2022
@katebatura katebatura added this to To do in Now via automation Jan 12, 2022
@katebatura katebatura moved this from To do to In progress in Now Jan 12, 2022
@katebatura katebatura linked a pull request Jan 12, 2022 that will close this issue
1 task
@katebatura katebatura moved this from In progress to Review in progress in Now Jan 12, 2022
@zhannapopenko
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Now
Review in progress
Development

Successfully merging a pull request may close this issue.

4 participants