Skip to content
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

bower_components
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Simple DateTime Picker For AngularJS
===================================

No JQuery, No Bootstrap, Just AngularJS (ver. 1.3+)
No JQuery, No Bootstrap, Just AngularJS (ver. 1.3+) and Moment.js(Required)

[DEMO](https://rawgit.com/kineticsocial/angularjs-datetime-picker/master/index.html)
[![Imgur](http://i.imgur.com/UJfYMN6.png?1)](https://rawgit.com/kineticsocial/angularjs-datetime-picker/master/index.html)
Expand Down
23 changes: 3 additions & 20 deletions angularjs-datetime-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,7 @@
if (attrs.ngModel) { // need to parse date string
var dateStr = ''+ctrl.triggerEl.scope().$eval(attrs.ngModel);
if (dateStr) {
if (!dateStr.match(/[0-9]{2}:/)) { // if no time is given, add 00:00:00 at the end
dateStr += " 00:00:00";
}
dateStr = dateStr.replace(/([0-9]{2}-[0-9]{2})-([0-9]{4})/,'$2-$1'); //mm-dd-yyyy to yyyy-mm-dd
dateStr = dateStr.replace(/([\/-][0-9]{2,4})\ ([0-9]{2}\:[0-9]{2}\:)/,'$1T$2'); //reformat for FF
dateStr = dateStr.replace(/EDT|EST|CDT|CST|MDT|PDT|PST|UT|GMT/g,''); //remove timezone
dateStr = dateStr.replace(/\s*\(\)\s*/,''); //remove timezone
dateStr = dateStr.replace(/[\-\+][0-9]{2}:?[0-9]{2}$/,''); //remove timezone
dateStr += getTimezoneOffset(dateStr);
var d = new Date(dateStr);
scope.selectedDate = new Date(
d.getFullYear(),
d.getMonth(),
d.getDate(),
d.getHours(),
d.getMinutes(),
d.getSeconds()
);
scope.selectedDate = moment(dateStr, dateFormat).toDate();
}
}

Expand Down Expand Up @@ -272,9 +255,9 @@
//console.log('attrs.ngModel',attrs.ngModel);
var elScope = ctrl.triggerEl.scope(), dateValue;
if (elScope.$eval(attrs.ngModel) && elScope.$eval(attrs.ngModel).constructor.name === 'Date') {
dateValue = new Date(dateFilter(scope.selectedDate, dateFormat));
dateValue = scope.selectedDate;
} else {
dateValue = dateFilter(scope.selectedDate, dateFormat);
dateValue = moment(scope.selectedDate).format(dateFormat);
}
elScope.$eval(attrs.ngModel + '= date', {date: dateValue});
}
Expand Down
2 changes: 1 addition & 1 deletion angularjs-datetime-picker.min.js

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

5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "angularjs-datetime-picker",
"main": "angularjs-datetime-picker.js",
"version": "0.1.20",
"homepage": "https://github.com/kineticsocial/angularjs-datetime-picker",
"homepage": "https://github.com/petervavro/angularjs-datetime-picker",
"authors": [
"Allen Kim <allen.kim@kineticsocial.com>"
],
Expand All @@ -23,6 +23,7 @@
"tests"
],
"dependencies": {
"angular": "~1.4.4"
"angular": "~1.4.4",
"moment": "^2.18.1"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"gulp-strip-debug": "^1.0.2",
"gulp-uglify": "^1.2.0",
"run-sequence": "^1.1.0"
}
},
"homepage": "https://github.com/kineticsocial/angularjs-datetime-picker"
}