Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

update README.md toString -> toISOString, Fix initial input value is Invalid Date in iOS Safari #300

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Option | Type | Default | Description
------------- | ------------- | ------------- | -------------
date-set="" | String | false | Set a default date to show and init datepicker
| | | **tip:** _Do not use same scope for ng-model="date" and date-set="{{date}}", this example is wrong._
| | | **tip:** _If you want to pass a Date Object inside do like this date-set="{{newDateObject.toString()}}"_
| | | **tip:** _If you want to pass a Date Object inside do like this date-set="{{newDateObject.toISOString()}}"_
| | | **tip:** _Consider that `date-set="{{myDate}}"` equals to `new Date(attr.dateSet)`, be sure the date you pass inside date-set="" is always in a correct ISO format, or adjust it based on the browser locale to avoid problems with that."._
date-format="" | String | String(new Date()) | Set the date format you want to use, see the list [here](https://docs.angularjs.org/api/ng/filter/date)
| | | **tip:** _Be always sure to use a recognized format, maybe try first of all to pass it through new Date('...') and see if it's recognized_
Expand Down
6 changes: 4 additions & 2 deletions dist/angular-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,10 @@
};

$scope.selectedMonthHandle = function manageSelectedMonthHandle(selectedMonthNumber) {

$scope.monthNumber = Number($filter('date')(new Date(selectedMonthNumber + '/01/2000'), 'MM'));
// in iOS Safari selectedMonthNumber is null at the start up
if (selectedMonthNumber) {
$scope.monthNumber = Number($filter('date')(new Date(selectedMonthNumber + '/01/2000'), 'MM'));
}
setDaysInMonth($scope.monthNumber, $scope.year);
setInputValue();
};
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-datepicker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-datepicker.sourcemap.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/js/angular-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,10 @@
};

$scope.selectedMonthHandle = function manageSelectedMonthHandle(selectedMonthNumber) {

$scope.monthNumber = Number($filter('date')(new Date(selectedMonthNumber + '/01/2000'), 'MM'));
// in iOS Safari selectedMonthNumber is null at the start up
if (selectedMonthNumber) {
$scope.monthNumber = Number($filter('date')(new Date(selectedMonthNumber + '/01/2000'), 'MM'));
}
setDaysInMonth($scope.monthNumber, $scope.year);
setInputValue();
};
Expand Down