Skip to content

Commit

Permalink
fix now and today utc; made usable with every elem (not only input)
Browse files Browse the repository at this point in the history
  • Loading branch information
scoletti committed Jan 12, 2017
1 parent 0ba63ad commit fd88bc5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mdPickers",
"version": "0.7.4",
"version": "0.7.5",
"homepage": "https://github.com/simonered/mdPickers",
"authors": [
"simonered"
Expand Down
18 changes: 12 additions & 6 deletions dist/mdPickers.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function DatePickerCtrl($scope, $mdDialog, $mdMedia, $timeout, currentDate, minD
return undefined;
}

m = (useUtc || utcOffset) ? moment().utc(true) : moment();
m = useUtc || utcOffset ? moment().utc(true) : moment();
}

m = moment.isMoment(m) ? m : moment(m);
Expand Down Expand Up @@ -99,7 +99,7 @@ function DatePickerCtrl($scope, $mdDialog, $mdMedia, $timeout, currentDate, minD
};

this.today = function() {
self.currentMoment = this.normalizeMoment(moment());
self.currentMoment = this.normalizeMoment();
this.selectYear(self.currentMoment.year());
};

Expand Down Expand Up @@ -419,7 +419,7 @@ function TimePickerCtrl($scope, $mdDialog, $mdMedia, time, autoSwitch, useUtc, u
return undefined;
}

m = (useUtc || utcOffset) ? moment().utc(true) : moment();
m = useUtc || utcOffset ? moment().utc(true) : moment();
}

if (useUtc) {
Expand Down Expand Up @@ -450,7 +450,7 @@ function TimePickerCtrl($scope, $mdDialog, $mdMedia, time, autoSwitch, useUtc, u
};

this.now = function() {
self.time = this.normalizeMoment(moment());
self.time = this.normalizeMoment();
};

this.cancel = function() {
Expand Down Expand Up @@ -873,8 +873,14 @@ module.directive("mdpTimePicker", ["$mdpTimePicker", "$timeout", function($mdpTi
return m;
};

ngModel.$setViewValue(normalizeMoment(moment(time)).format(scope.timeFormat));
ngModel.$render();
if (element[0].tagName == "input") {
ngModel.$setViewValue(normalizeMoment(time).format(scope.timeFormat));

} else {
ngModel.$setViewValue(normalizeMoment(time).toDate());
}

ngModel.$render();
});
};

Expand Down
2 changes: 1 addition & 1 deletion dist/mdPickers.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mdPickers.min.js.map

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
@@ -1,6 +1,6 @@
{
"name": "mdPickers",
"version": "0.7.4",
"version": "0.7.5",
"description": "Fork of alenaksu/mdPickers: Material Design date/time pickers for Angular Material",
"main": "gulpfile.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/mdDatePicker/mdDatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function DatePickerCtrl($scope, $mdDialog, $mdMedia, $timeout, currentDate, minD
return undefined;
}

m = (useUtc || utcOffset) ? moment().utc(true) : moment();
m = useUtc || utcOffset ? moment().utc(true) : moment();
}

m = moment.isMoment(m) ? m : moment(m);
Expand Down Expand Up @@ -92,7 +92,7 @@ function DatePickerCtrl($scope, $mdDialog, $mdMedia, $timeout, currentDate, minD
};

this.today = function() {
self.currentMoment = this.normalizeMoment(moment());
self.currentMoment = this.normalizeMoment();
this.selectYear(self.currentMoment.year());
};

Expand Down
14 changes: 10 additions & 4 deletions src/components/mdTimePicker/mdTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function TimePickerCtrl($scope, $mdDialog, $mdMedia, time, autoSwitch, useUtc, u
return undefined;
}

m = (useUtc || utcOffset) ? moment().utc(true) : moment();
m = useUtc || utcOffset ? moment().utc(true) : moment();
}

if (useUtc) {
Expand Down Expand Up @@ -52,7 +52,7 @@ function TimePickerCtrl($scope, $mdDialog, $mdMedia, time, autoSwitch, useUtc, u
};

this.now = function() {
self.time = this.normalizeMoment(moment());
self.time = this.normalizeMoment();
};

this.cancel = function() {
Expand Down Expand Up @@ -475,8 +475,14 @@ module.directive("mdpTimePicker", ["$mdpTimePicker", "$timeout", function($mdpTi
return m;
};

ngModel.$setViewValue(normalizeMoment(moment(time)).format(scope.timeFormat));
ngModel.$render();
if (element[0].tagName == "input") {
ngModel.$setViewValue(normalizeMoment(time).format(scope.timeFormat));

} else {
ngModel.$setViewValue(normalizeMoment(time).toDate());
}

ngModel.$render();
});
};

Expand Down

0 comments on commit fd88bc5

Please sign in to comment.