Skip to content

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

Closed

Description

@belavenuto

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.

Activity

  1. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Jan 25, 2018
  2. anymos commented on Feb 24, 2018

    @anymos

    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');

  3. irowbin commented on Feb 24, 2018

    @irowbin

    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! 👍

  4. mmalerba commented on Feb 24, 2018

    @mmalerba
    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)

  5. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions