|
276 | 276 |
|
277 | 277 | $scope.year = Number($scope.year) + 1;
|
278 | 278 | }
|
| 279 | + , localDateTimestamp = function localDateTimestamp(rawDate, dateFormatDefinition) { |
| 280 | + |
| 281 | + 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 |
| 282 | + ,formatDate,dateSplit, m, d, y, index, el, longName, shortName; |
| 283 | + |
| 284 | + for (index = 0; index < datetime.MONTH.length; index += 1) { |
| 285 | + longName = datetime.MONTH[index]; |
| 286 | + shortName = datetime.SHORTMONTH[index]; |
| 287 | + |
| 288 | + if (rawDate.indexOf(longName) !== -1) { |
| 289 | + rawDate = rawDate.replace(longName, index + 1); |
| 290 | + break; |
| 291 | + } |
| 292 | + |
| 293 | + if (rawDate.indexOf(shortName) !== -1) { |
| 294 | + rawDate = rawDate.replace(shortName, index + 1); |
| 295 | + break; |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + dateSplit = rawDate |
| 300 | + .split(/\D/) |
| 301 | + .filter(function dateSplitFilter(item) { |
| 302 | + return item.length > 0; |
| 303 | + }); |
| 304 | + |
| 305 | + formatDate = dateFormatDefinition |
| 306 | + .match(formattingTokens) |
| 307 | + .filter(function fromatDateFilter(item) { |
| 308 | + return item.match(/^[a-zA-Z]+$/i) !== null; |
| 309 | + }); |
| 310 | + |
| 311 | + for (index = 0; index < formatDate.length; index += 1) { |
| 312 | + el = formatDate[index]; |
| 313 | + |
| 314 | + switch (true) { |
| 315 | + case el.indexOf('d') !== -1: { |
| 316 | + d = dateSplit[index]; |
| 317 | + break; |
| 318 | + } |
| 319 | + case el.indexOf('M') !== -1: { |
| 320 | + m = dateSplit[index]; |
| 321 | + break; |
| 322 | + } |
| 323 | + case el.indexOf('y') !== -1: { |
| 324 | + y = dateSplit[index]; |
| 325 | + break; |
| 326 | + } |
| 327 | + default: { |
| 328 | + break; |
| 329 | + } |
| 330 | + } |
| 331 | + } |
| 332 | + |
| 333 | + return new Date(y + '/' + m + '/' + d); |
| 334 | + } |
279 | 335 | , setInputValue = function setInputValue() {
|
280 | 336 |
|
281 | 337 | if ($scope.isSelectableMinDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.day) &&
|
|
619 | 675 | thisInput[0].value.length > 0) {
|
620 | 676 |
|
621 | 677 | try {
|
622 |
| - |
623 | 678 | if (dateFormat) {
|
624 |
| - date = new Date($filter('date')(thisInput[0].value.toString(), dateFormat)); |
| 679 | + date = localDateTimestamp(thisInput[0].value.toString(), dateFormat); |
625 | 680 | } else {
|
626 | 681 | date = new Date(thisInput[0].value.toString());
|
627 | 682 | }
|
|
0 commit comments