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

fix(datepicker): support string in the non-HTML5 formatter #6439

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

byronigoe
Copy link

support string in the non-HTML5 formatter, e.g. JSON date

The formatter for non-HTML5 inputs had logic to convert a Number into a Date (Object), but nothing for Strings (like JSON dates).
Copy link
Contributor

@wesleycho wesleycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change, but I'm amenable to merging this otherwise.

@@ -119,7 +119,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
return value;
}

if (angular.isNumber(value)) {
if (!angular.isObject(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to do !angular.isDate here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@byronigoe
Copy link
Author

For my use case of using a JSON date, I also needed to enhance the validator:
if (angular.isString(value)) {
return !isNaN(parseDateString(value)) || value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.000Z$/);
}

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

Successfully merging this pull request may close these issues.

2 participants