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

Commit

Permalink
see #243 thanks to @bender404
Browse files Browse the repository at this point in the history
  • Loading branch information
45kb committed Mar 4, 2017
1 parent 9f8e62f commit b74a3e0
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-datepicker",
"version": "2.1.13",
"version": "2.1.14",
"description": "A datepicker directive for angularjs.",
"authors": [
"Filippo Oretti <filippo.oretti@gmail.com",
Expand Down
3 changes: 1 addition & 2 deletions dist/angular-datepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ datepicker, .datepicker, [datepicker],
border-radius: 1px;
}
._720kb-datepicker-calendar-day:hover,
._720kb-datepicker-calendar-day._720kb-datepicker-active,
._720kb-datepicker-calendar-day._720kb-datepicker-today {
._720kb-datepicker-calendar-day._720kb-datepicker-active {
background: rgba(0, 0, 0, 0.03);
}
._720kb-datepicker-calendar-header a, ._720kb-datepicker-calendar-header a:hover {
Expand Down
59 changes: 57 additions & 2 deletions dist/angular-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,62 @@

$scope.year = Number($scope.year) + 1;
}
, localDateTimestamp = function localDateTimestamp(rawDate, dateFormatDefinition) {

var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|MMMM|MMM|MM|M|dd?d?|yy?yy?y?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g
,formatDate,dateSplit, m, d, y, index, el, longName, shortName;

for (index = 0; index < datetime.MONTH.length; index += 1) {
longName = datetime.MONTH[index];
shortName = datetime.SHORTMONTH[index];

if (rawDate.indexOf(longName) !== -1) {
rawDate = rawDate.replace(longName, index + 1);
break;
}

if (rawDate.indexOf(shortName) !== -1) {
rawDate = rawDate.replace(shortName, index + 1);
break;
}
}

dateSplit = rawDate
.split(/\D/)
.filter(function dateSplitFilter(item) {
return item.length > 0;
});

formatDate = dateFormatDefinition
.match(formattingTokens)
.filter(function fromatDateFilter(item) {
return item.match(/^[a-zA-Z]+$/i) !== null;
});

for (index = 0; index < formatDate.length; index += 1) {
el = formatDate[index];

switch (true) {
case el.indexOf('d') !== -1: {
d = dateSplit[index];
break;
}
case el.indexOf('M') !== -1: {
m = dateSplit[index];
break;
}
case el.indexOf('y') !== -1: {
y = dateSplit[index];
break;
}
default: {
break;
}
}
}

return new Date(y + '/' + m + '/' + d);
}
, setInputValue = function setInputValue() {

if ($scope.isSelectableMinDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.day) &&
Expand Down Expand Up @@ -619,9 +675,8 @@
thisInput[0].value.length > 0) {

try {

if (dateFormat) {
date = new Date($filter('date')(thisInput[0].value.toString(), dateFormat));
date = localDateTimestamp(thisInput[0].value.toString(), dateFormat);
} else {
date = new Date(thisInput[0].value.toString());
}
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-datepicker.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b74a3e0

Please sign in to comment.