Skip to content

Commit

Permalink
fix(datepicker): ng-model value can be a timestamp
Browse files Browse the repository at this point in the history
Accept a number of milliseconds since 01.01.1970 as a valid value
for `ng-model`

Closes angular-ui#2345
  • Loading branch information
khashayar committed Feb 21, 2015
1 parent 23936f9 commit 81f8ee4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
}

function parseDate(viewValue) {
if (angular.isNumber(viewValue)) {
// presumably timestamp to date object
viewValue = new Date(viewValue);
}

if (!viewValue) {
ngModel.$setValidity('date', true);
return null;
Expand Down

0 comments on commit 81f8ee4

Please sign in to comment.