-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Support ng-model-options with datepicker #4837
Comments
I would really like to set UTC timezone instead of local or without time/timezone when setting a date using the datepicker! |
👍 |
@maxdeviant, please don't add We know this is something users want and fully intend to implement it. We have a lot on our plates at the moment trying to get 1.0 out the door. |
I should also add that we welcome well-thought and well-developed PRs if you really want/need this feature sooner rather than later. |
My apologies. It's a bit of a force of habit, at this point.
|
I fixed my issue with timezone for now with this directive. Posting here in case any one needs. https://gist.github.com/sandeepthomas/78f2de3f0f8f21869f91 It removes the timezone and converts the date to epoch/unix time. |
For firebase timestamps I am using this directive. .directive('timestamp', function($filter) {
return {
restrict: 'A',
require: ['ngModel'],
link: function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];
var format = attr.uibDatepickerPopup;
if (format) {
ngModelController.$parsers.push(function(viewValue) {
if (!viewValue) {
return undefined;
}
// Strip off timezone offset
if (angular.isFunction(viewValue.getTime)) {
viewValue.setMinutes(viewValue.getMinutes() - viewValue.getTimezoneOffset());
return viewValue.getTime();
} else {
return undefined;
}
});
ngModelController.$formatters.push(function(modelValue) {
if (!modelValue) {
return undefined;
}
// Display the actual time, not local time
return $filter('date')(modelValue, format, '+00:00');
});
}
}
};
}) |
@davious nice work sir, I just played with your timezone commit and I like it! There are a couple of issues I noticed: the calendar is ahead by one day, and the time moves ahead by one hour when you select a DST date (i.e.: March 7 vs March 14) |
I was working on the timezone issue locally as well, as it turns out to be quite tricky - I have it completely working for the inline datepicker, but not the one in the popup. I also have to rejig the tests. For anyone working on this issue - a new method should be added to the |
@paulflo150 according to http://stackoverflow.com/questions/16946002/javascript-time-zone-is-wrong-for-past-daylight-saving-time-transition-rules/16951442#16951442 there is a design flaw in ECMAScript that makes DST handling flaky. Perhaps this explains the issue you experienced. |
Regarding updateOn: blur support - I also can’t update past 0.14.x now as our date-pickers stop working. The scenario we’d like is to have the blur functionality on the input field but still want the field updated when the user makes a selection from the popup. At the moment the same ng-model-options get used for both and the popup selection no longer works. Happy to look at a PR but not sure what the preferred approach would be. A couple of potential solutions:
Either of those sound acceptable? |
I have a drop down containing various time zones. when i select a timezone, the datepicker should be updated automatically. Is it possible to adjust ui-datepicker for selected timezone |
I was just following up on @mlev 's idea (1) for supporting I'd be happy to provide a PR, if there are no further concerns about this approach. What do you think, @wesleycho? |
Yes, please! This is causing some frustrating issues for me right now. |
The timezone issue is fixed.
To get a datepicker without timezone calculation. |
I'm not sure what would be desired exactly for updateOn - would need to investigate. I welcome any PRs that make sense though with tests to make it clear what is desired. |
@wesleycho Alright, i'll try to come up with a PR containing some tests. If you find any use for updateOn, please let me know! |
To give an update, |
I took an investigation into implementing |
"fundamental flaw with it given that we are allowing setting ng-model-options through alternative means, so we are feature complete as far as ng-model-options support goes for the datepicker." What does that mean? Did getterSetter ever make it to 2.0? Thanks |
It seems to work now, but users can only type into the text field if I also include "updateOn:Blur". e.g. |
@wald-tq the provided solution doesn't work for me :( , Any guess? |
@pankajparkar : I am still using 1.2.x of angular-bootstrap. That's my only guess I with that much information. |
@wald-tq That's correct guess, I'm using |
@pankajparkar I can't help you. Consider a upgrade. |
We should support ng-model-options with the datepicker
In particular, we should support
allowInvalid
updateOn
timezone
The text was updated successfully, but these errors were encountered: