Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

TypeError: date.getTimezoneOffset is not a function #5871

Closed
mebibou opened this issue May 3, 2016 · 2 comments
Closed

TypeError: date.getTimezoneOffset is not a function #5871

mebibou opened this issue May 3, 2016 · 2 comments

Comments

@mebibou
Copy link
Contributor

mebibou commented May 3, 2016

Bug description:

ng-model as numeric does not work properly when using datepicker-popup. By looking at this line from the source code, I would say that the check for numeric value should be done before and not after, i.e.:

$scope.date = dateParser.fromTimezone(value, timezone);

if (angular.isNumber($scope.date)) {
  $scope.date = new Date($scope.date);
}

Should be instead:

if (angular.isNumber(value)) {
  value = new Date(value);
}

$scope.date = dateParser.fromTimezone(value, timezone);

Because dateParser.fromTimezone expects a Date and not a Number, the error TypeError: date.getTimezoneOffset is not a function is thrown.

Version of Angular, UIBS, and Bootstrap

Angular: 1.5.5
UIBS: 1.3.2
Bootstrap: 3.3.5

@icfantv
Copy link
Contributor

icfantv commented May 3, 2016

I'm on my phone, but at first glance this looks legit. @wesleycho?

@wesleycho
Copy link
Contributor

wesleycho commented May 3, 2016

This sounds legit, but our intention is to officially remove support for non-date objects for the datepicker.

Feel free to file a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants