NbDatePicker works with dates passed as strings, but throws error in console
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.1k
- Forks
- 1.5k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### Issue type
**I'm submitting a ...** (check one with "x")
* [X] bug report
* [X] feature request
I'm marking both bug report and feature request as this can be either depending on how you want to solve it. IMHO it would be enough to add few clarifications in the docs on what type of value expects the date picker.
### Issue description
**Current behavior:**
When clicking on the `input` element to which a datepicker is bound, if a full date (full date meaning a date previously generated with the date picker and then stored in a DB as a string) is set in `currentValue` of the `input` as a string, the following message appears twice in the console.
ERROR TypeError: date.getMonth is not a function
at NbNativeDateService.getMonthName (index.js:8167)
at NbCalendarViewModeComponent.getText (index.js:7446)
at NbCalendarViewModeComponent_Template (index.js:7484)
at executeTemplate (core.js:9599)
at refreshView (core.js:9465)
at refreshComponent (core.js:10636)
at refreshChildComponents (core.js:9261)
at refreshView (core.js:9515)
at refreshEmbeddedViews (core.js:10590)
at refreshView (core.js:9489)
In the docs it should be mentioned that the date passed should be a date Object, or NbDatePicker should be able to parse a string to a date object (`const dateObject = new Date(fullDateAsASting)`).
Note that even if a string is passed, date picker works as expected.
**Expected behavior:**
No error in console if a string is passed, instead of a date object || Docs clarifying that a date Object must be passed.
**Steps to reproduce:**
Create a date picker and pass it a full date as a string.
**Related code:**
```
dateValueAsString = "2021-10-20T22:00:00.000Z";
```
### Other information:
**npm, node, OS, Browser**
```
node v14.18.0
npm v6.14.15
OS: Windows 10
Browser: Edge and Chrome (both latest version)
```
**Angular, Nebular**
```
"@angular/animations": "^12.2.9",
"@angular/cdk": "^11.0.0",
"@angular/common": "^12.2.9",
"@angular/compiler": "^12.2.9",
"@angular/core": "^12.2.9",
"@angular/forms": "^12.2.9",
"@angular/platform-browser": "^12.2.9",
"@angular/platform-browser-dynamic": "^12.2.9",
"@angular/router": "^12.2.9",
"@angular/service-worker": "^12.2.9",
"@nebular/eva-icons": "^8.0.0",
"@nebular/theme": "^8.0.0",
```
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.