Skip to content

Commit 543a8c8

Browse files
committed
allow specifying date/time format for moment
1 parent 55cf605 commit 543a8c8

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ For both date and time input
5151
| date | moment.js datetime object or a datetime string | none | no |
5252
| time | moment.js datetime object or a datetime string | none | no |
5353
| datetime | moment.js datetime object or a datetime string | none | no |
54+
| format | moment.js compatible date/time format | none | no |
5455
| placeholder | Placeholder is shown when input object is undefined | none | no |
5556
| on-change | Handler function that is fired on change of datetime object | none | no |
5657

dist/datetime-input.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/date-input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ directive('dateInput', ['$document', function ($document) {
99
restrict: 'E',
1010
scope: {
1111
date: '=',
12+
format: '=',
1213
onChange: '&',
1314
placeholder: '@'
1415
},
@@ -53,7 +54,7 @@ directive('dateInput', ['$document', function ($document) {
5354

5455
// Convert date object to moment.js if its not a moment object yet
5556
if ( scope.date && !scope.date._isAMomentObject ) {
56-
scope.date = moment(scope.date);
57+
scope.date = moment(scope.date, scope.format);
5758
}
5859

5960
// Bind click events outside directive to close edit popover

0 commit comments

Comments
 (0)