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

Commit

Permalink
Fix for NaN instead of dates and months names when wrong data placed …
Browse files Browse the repository at this point in the history
…in input field, fixes [#26](#26) and [#27](#27)
  • Loading branch information
nazar-pc committed Jul 11, 2014
1 parent 4eda6c4 commit 766742a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pickmeup",
"version": "2.4.0",
"version": "2.4.1",
"homepage": "https://github.com/nazar-pc/PickMeUp",
"authors": [
"Nazar Mokrynskyi <nazar@mokrynskyi.com>"
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.4.1 (11 July, 2014)
* Fix for NaN instead of dates and months names when wrong data placed in input field, fixes [#26](https://github.com/nazar-pc/PickMeUp/issues/26) and [#27](https://github.com/nazar-pc/PickMeUp/issues/27)

2.4.0 (01 July, 2014)
* Add methods prev/next for external call

Expand Down
6 changes: 5 additions & 1 deletion js/jquery.pickmeup.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,18 @@
break;
}
}
return new Date(
var parsed_date = new Date(
y === undefined ? now.getFullYear() : y,
m === undefined ? now.getMonth() : m,
d === undefined ? now.getDate() : d,
h === undefined ? now.getHours() : h,
min === undefined ? now.getMinutes() : min,
0
);
if (parsed_date.toString() == 'Invalid Date') {
parsed_date = new Date;
}
return parsed_date;
}
function formatDate (date, format, locale) {
var m = date.getMonth();
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.pickmeup.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"date",
"calendar"
],
"version" : "2.4.0",
"version" : "2.4.1",
"homepage" : "https://github.com/nazar-pc/PickMeUp",
"author" : {
"name" : "Nazar Mokrynskyi",
Expand Down
2 changes: 1 addition & 1 deletion pickmeup.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"date",
"calendar"
],
"version" : "2.4.0",
"version" : "2.4.1",
"homepage" : "https://github.com/nazar-pc/PickMeUp",
"author" : {
"name" : "Nazar Mokrynskyi",
Expand Down

2 comments on commit 766742a

@mxp100
Copy link

@mxp100 mxp100 commented on 766742a Jul 16, 2014

Choose a reason for hiding this comment

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

if (parsed_date.toString() == 'Invalid Date')
Это некорректное решение, т.к. не во всех версиях javascript выдается именно такая строковая ошибка(к примеру даже firefox выдает ошибку Invalid date, т.е. с маленькой буквой), более надежно это попытаться потом получить timestamp - и если он NaN, то и делать на основании этого вывод. Тем более что оно ничем не хуже

@nazar-pc
Copy link
Owner Author

Choose a reason for hiding this comment

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

723c241, прекращайте писать на русском, люди читают разные, и получается, что многие не могут понять что вы пишете.

Please sign in to comment.