Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(datepicker): correctly display pre-100 years #4812

Closed
wants to merge 1 commit into from

Conversation

wesleycho
Copy link
Contributor

  • Fix display of dates in datepicker for years less than 100

Here is a Plunker in action.

This fixes #4032.

- Fix display of dates in datepicker for years less than 100
@@ -246,6 +246,7 @@ angular.module('ui.bootstrap.dateparser', [])
dt = new Date(fields.year, fields.month, fields.date,
fields.hours, fields.minutes, fields.seconds,
fields.milliseconds || 0);
dt.setFullYear(fields.year);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

@Foxandxss
Copy link
Contributor

Can you explain to me how this work? I made a note but then realized that all the PR was add stuff like that and I don't follow the idea.

@wesleycho
Copy link
Contributor Author

The problem with setting a date with new Date(year, month, day) is that it interprets new Date(3, 1, 2) as February 2, 1903 instead of February 2, 3 - one has to manually call setFullYear in order to properly set the year.

@Foxandxss
Copy link
Contributor

I see. Good for me.

@wesleycho wesleycho closed this in beabb4a Nov 3, 2015
@wesleycho wesleycho deleted the fix/old-dates branch November 3, 2015 13:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot select pre-100 years
2 participants