angular: [Safari only] Invalid argument for pipe 'DatePipe' - Safari cannot parse Date offsets
I’m submitting a …
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Error shows up, only on Safari (Version 10.0 (11602.1.50.0.10))
Expected behavior
Expected no error to show up. Google Chrome works fine
Minimal reproduction of the problem with instructions
Go to the following Plunkr with Safari and Google Chrome. Chrome works perfectly.
Plunkr: https://plnkr.co/edit/8ieBbla6Pk3jFQKkHsNc?p=preview
What is the motivation / use case for changing the behaviour?
So it works on Safari as well as Chrome
Please tell us about your environment:
Max OS X El Capitan 10.11.6
-
Angular version: 2.0.0
-
Browser: Chrome Latest, Safari 10.0 (11602.1.50.0.10), iOS Safari
-
Language: TypeScript 2.0.2
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 16 (1 by maintainers)
Commits related to this issue
- fix(DatePipe): parse string input ourselves to avoid inconsistency between browsers Closes #12334 Closes #13874 — committed to DzmitryShylovich/angular by DzmitryShylovich 7 years ago
- fix(DatePipe): parse string input ourselves to avoid inconsistency between browsers Closes #12334 Closes #13874 — committed to DzmitryShylovich/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser Closes #12334 Closes #13874 — committed to DzmitryShylovich/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser Closes #12334 Closes #13874 — committed to DzmitryShylovich/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to angular/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to angular/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to mhevery/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to mhevery/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to asnowwolf/angular by DzmitryShylovich 7 years ago
- fix(common): DatePipe parses input string if it's not a valid date in browser (#13895) Closes #12334 Closes #13874 PR Close #13895 — committed to juleskremer/angular by DzmitryShylovich 7 years ago
It’s still a bug in safari when you have date like that: 2017-11-02 00:00:00.000
edit:
'2017-11-02 00:00:00.000'.replace(/\s/g, "T")
this work’s in Safari and Chrome.This issue is still here
This will work as a temporary solution. Of course, you can replace the replaced string value with what you require, e.g. hyphen instead of comma.
Then use it like this:
I have a strong feeling it is somewhat related to this:
http://stackoverflow.com/questions/6427204/date-parsing-in-javascript-is-different-between-safari-and-chrome
https://github.com/pushtell/react-bootstrap-date-picker/issues/2