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

DatePicker: dd/mm/yy date format through ref is displaying NaN on datepicker #7010

Closed
debashish4 opened this issue Dec 26, 2024 · 3 comments
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@debashish4
Copy link

debashish4 commented Dec 26, 2024

Describe the bug

When using the "dd/mm/yy" date format in ref, the displayed output is NaN/NaN/NaN instead of the expected date format. This issue is happening in primeVue 4.2.5

`

<script setup> import { ref } from 'vue'; const date = ref('25/12/2024'); </script>

`

Reproducer

https://stackblitz.com/edit/primevue-4-vite-issue-template-udtg8djk

PrimeVue version

4.2.5

Vue version

4.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

chrome

Steps to reproduce the behavior

Steps to Reproduce

  1. Set the date format to dd/mm/yy.
  2. Pass a valid date object or string to the date formatting function.
  3. Observe the output displayed as NaN/NaN/NaN.

NOTE: it doesn't work with the version "4.2.5"

Ex:


<script setup> import { ref } from 'vue'; const date = ref('25/12/2024'); </script>

Expected behavior

I expect when i pass a date dd/mm/yyyy format to ref. eg const date = ref('25/12/2024'); and bind through v-model of datepicker. It should display 25/12/2024 instead of NaN/NaN/NaN

@debashish4 debashish4 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 26, 2024
@debashish4 debashish4 changed the title DatePicker: Date Format Display Error DatePicker: dd/mm/yy date format through ref is displaying NaN on datepicker Dec 26, 2024
@cagataycivici cagataycivici added this to the 4.2.6 milestone Dec 27, 2024
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Dec 27, 2024
@github-project-automation github-project-automation bot moved this to Review in PrimeVue Dec 27, 2024
@mertsincan mertsincan removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 27, 2024
@tugcekucukoglu
Copy link
Member

Cannot replicate the issue. A working example: https://stackblitz.com/edit/wsaz75bq?file=src%2FApp.vue

@antlionguard
Copy link
Contributor

antlionguard commented Jan 1, 2025

Cannot replicate the issue. A working example: https://stackblitz.com/edit/wsaz75bq?file=src%2FApp.vue

image

If there's assigned empty string the issue occurs.

@KumJungMin
Copy link
Contributor

Because of the new Date(value) is 'invalid Date', the date is 'NaN'

related PR: https://github.com/primefaces/primevue/pull/6931/files

if (typeof value === 'string') {
return this.dateFormat ? this.formatDate(new Date(value), this.dateFormat) : value;
}

@github-project-automation github-project-automation bot moved this from Review to Done in PrimeVue Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
Status: Done
Development

No branches or pull requests

6 participants