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: Year selection mode doesn't work with years before 1986 #9534

Closed
belavenuto opened this issue Jan 23, 2018 · 4 comments · Fixed by #10068
Closed

Datepicker: Year selection mode doesn't work with years before 1986 #9534

belavenuto opened this issue Jan 23, 2018 · 4 comments · Fixed by #10068
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@belavenuto
Copy link

belavenuto commented Jan 23, 2018

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Select year before 1986 correctly through "year selection mode", implemented in #8565

What is the current behavior?

The year 1985 is missing, so when you select any year before 1986, it selects a year later, for example, when you select 1981, datepicker selects 1982.

What are the steps to reproduce?

The issue can be observed on Material docs, https://material.angular.io/components/datepicker/overview

3y6t1ujavu

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: 5.1.3
Material: 5.1.0
OS: Windows 7
TypeScript: 2.6.2
Browsers:

  • Chrome Version 63.0.3239.132 (Official Build) (64-bit)
  • Firefox Version 57.0.4 (64-bit)

Is there anything else we should know?

On IE 11, the behavior is correct.

@mmalerba mmalerba added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jan 25, 2018
@anymos
Copy link

anymos commented Feb 24, 2018

Hi there in any case that it might be usefull, some of the device were having the same kind of weird issue.

We fixed it by fixing the locale in the constructor in english, following the french exemple in the doc as per 👍

providers: [
// The locale would typically be provided on the root module of your application. We do it at
// the component level here, due to limitations of our example generation script.
{provide: MAT_DATE_LOCALE, useValue: 'en-US'},

    // `MomentDateAdapter` and `MAT_MOMENT_DATE_FORMATS` can be automatically provided by importing
    // `MatMomentDateModule` in your applications root module. We provide it at the component level
    // here, due to limitations of our example generation script.
    {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
    {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
]

this.adapter.setLocale('en');

@irowbin
Copy link

irowbin commented Feb 24, 2018

Hi @anymos The datepicker working as expected after adding your example from above but, I think this is not a correct way or maybe not. I don't know 😆 but Thanks anyway! 👍

@mmalerba
Copy link
Contributor

That workaround works because the bug is caused by the way DST is handled, and different locales have different DST rules. The real fix is to convert the dates to UTC for consistency before formatting. (coming in #10068)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants