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 providing only two digits for the year input is parsed to 19_ _ instead of 20_ _ #8475

Closed
mmart1n opened this issue Oct 28, 2020 · 4 comments · Fixed by #9160
Closed

Comments

@mmart1n
Copy link
Contributor

mmart1n commented Oct 28, 2020

Description

A customer is using a DatePicker in dropdown mode with the default mask. When entering a shorter year such as 5/17/20 it first looks right, but instead of using the current year it uses the year 1920.

  • igniteui-angular version: 10.2.x, 9.1.x
  • browser: any

Steps to reproduce

  1. Open the following sample: https://stackblitz.com/edit/github-datepikcer-two-digit-year
  2. Enter the following value: 06/15/21
  3. Click outside the datePicker

Result

The created date is 06/15/1921

Expected result

The created date should be 06/15/2021

Attachments

Attach a sample if available, and screenshots, if applicable.

@damyanpetev
Copy link
Member

Since the sample already specifies the format explicitly, if you actually use the two-digit format and (more importantly) mask the parsed values will actually be as expected:

<igx-date-picker format="M/d/yy" mask="M/d/yy">

Here's the updated sample.

At the moment, the Date Picker will only prefix values with 20- if the editing mask is the two-digit format and that's also static. Otherwise, the value as parsed is used to create a new date, which for new Date(21, 05, 15) will produce Jun 15 1921.

Note that this behavior will change once we go through a refactor of the Date Picker to use the new igxDateTimeEditor directive internally, which will handle two-digit values even in four digit format and will assume those are 2k years with threshold at 50 right now, though that's also a good feature request to make it controllable.

PS: Funny thing is JS Date is a bit inconsistent as new Date("Jun 15 21") will actually result in 2021 as the year :D

@jackofdiamond5
Copy link
Member

The issue will be resolved in #6483

@github-actions
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Jan 25, 2021
@jackofdiamond5 jackofdiamond5 removed the status: inactive Used to stale issues and pull requests label Jan 25, 2021
@github-actions
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Mar 27, 2021
@Lipata Lipata removed the status: inactive Used to stale issues and pull requests label Mar 29, 2021
@Lipata Lipata mentioned this issue Apr 14, 2021
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants