fragaria / angular-daterangepicker

Angular.js wrapper for dangrossman/bootstrap-daterangepicker
MIT License
519 stars 371 forks source link

end time is a day more than specified #102

Closed eassa closed 5 years ago

eassa commented 9 years ago

i am having this issue that when i use custom range and i click the end date , it shows for the user the right endDate , but in the javascript i am recieving an extra day :- see photos (though i am setting it to be the 23rd it returns the 24th) [start Date is good though]

date inwatch

ghost commented 9 years ago

@eassa Looks like your date is in UTC instead of local time. Don't know for sure though http://momentjs.com/docs/#/parsing/utc/

eassa commented 9 years ago

this is my $watch , now the thing is that the dates are wrong only when i click on apply . the opts are fine and the first cal is good , but when i apply new custom date , only the endDate is a day more

$scope.$watch('userdate', function(newDate,oldDate) {           
            if (timer !== null) {
                $timeout.cancel(timer);
            }           
            timer = $timeout(function(){
                if (!angular.isDefined($scope.userdate) || !angular.isDefined($scope.userdate.startDate)) {
                    $scope.userdate = {
                        startDate: moment().subtract(29, 'days'),
                        endDate: moment()
                    };
                }
                if(newDate != oldDate && !(angular.isNumber(oldDate)&& angular.isNumber(newDate)) ){
                    ufetch($scope.userid,'all');
                }
            }, 400);
        }, false);
        $scope.opts = {
            ranges: {
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 15 Days': [moment().subtract(15, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()]
            }
        };

edit: formating

krtek commented 9 years ago

Please try new version 0.2.0

eassa commented 9 years ago

updating the Bootstrap Datepicker fixed the issue :) , but trying to update the angular-daterangepicker.js it tells me "Don't make functions within a loop." Line 151:- for (eventType in _ref) { callbackFunction = _ref[eventType]; _results.push(el.on(eventType, function() { return $scope.$evalAsync(callbackFunction); }));

krtek commented 9 years ago

Yes, but it's just a warning, isn't it?

eassa commented 9 years ago

yes , but it i am using playframework , such warnings does not let me compile my code , i will look into it if i can manage to skip this particular issue , but it could be awesome if you can do something about it