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

[date-picker] Allow 2-digit years (i.e. dates before year 100) #1600

Closed
zanonmark opened this issue Mar 14, 2021 · 5 comments
Closed

[date-picker] Allow 2-digit years (i.e. dates before year 100) #1600

zanonmark opened this issue Mar 14, 2021 · 5 comments
Labels
vaadin-date-picker waiting for author Further information is requested

Comments

@zanonmark
Copy link

Description

When (Enhanced)DatePicker is set to use "dd/MM/yyyy" as pattern and "dd/MM/yyyy", "dd/MM/yy" as parsers, inputting a year before 100 will result in a wrong date being reformatted.

i.e.: 13/01/0040 or 13/01/40 (13th January 40, not 1940 or 2040)
-> result: 1940-01-13

Expected outcome

The string should be parsed properly as 0040-01-13.

At this point, this component is unable to handle dates before year 100.

Thanks,
MZ

@zanonmark zanonmark changed the title Initialize Date() in ISO-8601 format Allow 2-digit years (i.e. dates before year 100) Mar 14, 2021
@zanonmark
Copy link
Author

zanonmark commented Mar 15, 2021

I read this CookBook recipe: instead of initializing the JavaScript Date() object as a (year, month, day) triple in i18n.formatDate(), shouldn't it use an ISO-8601-formatted date string?
I tried it at home and it works...

Thanks,
MZ

@tomivirkki
Copy link
Member

If the issue is about how the Enhanced Date Picker parses the date string, and not about vaadin-date-picker specifically, please report the issue in https://github.com/vaadin-component-factory/enhanced-date-picker

@zanonmark
Copy link
Author

zanonmark commented Mar 17, 2021

No, it's also for DatePicker: try https://vaadin.com/components/vaadin-date-picker/java-examples, pick the first example and enter 3/17/0084 (US locale), it will become 3/17/1984.

EnhancedDatePicker just inherits this issue.

Thanks,
MZ

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-date-picker May 19, 2021
@vaadin-bot vaadin-bot added vaadin-date-picker waiting for author Further information is requested labels May 19, 2021
@web-padawan web-padawan changed the title Allow 2-digit years (i.e. dates before year 100) [date-picker] Allow 2-digit years (i.e. dates before year 100) May 20, 2021
@zanonmark
Copy link
Author

zanonmark commented Aug 14, 2021

@web-padawan (I think the "waiting for author" tag is wrong here...)

Thanks,
MZ

@web-padawan
Copy link
Member

Sorry about the lack of response since the last comment.
This is now supported with the custom date format feature available in Vaadin 22:

https://vaadin.com/docs/latest/ds/components/date-picker/#date-format

format

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vaadin-date-picker waiting for author Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants