Export to GitHub

phantomjs - issue #187

PhantomJS seems to break on ISO8601 Date format


Posted on Aug 5, 2011 by Happy Horse

Which version of PhantomJS are you using? 1.1.0

What steps will reproduce the problem? 1. new Date('2011-06-17T10:00:00+00:00');

What is the expected output? What do you see instead? Output is "Invalid Date", but it should return a date object

Which operating system are you using? Centos 5 or Mac OSX

Did you use binary PhantomJS or did you compile it from source? DMG for Mac OSX, mixture on Centos

Please provide any additional information below.

Javascript 1.8.5 has implimented ISO8601 date format (spec here: http://www.w3.org/TR/NOTE-datetime, mozdocs here: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse). It seems as though Phantom does not parse these, throwing invalid date.

This works on Chrome 12, Firefox 4. Probably earlier versions too.

Comment #1

Posted on Aug 5, 2011 by Quick Rabbit

Probably not available in the QtWebKit module which PhantomJS uses.

Comment #2

Posted on Aug 9, 2011 by Quick Panda

According to the QTWebKit docs, this is available and should be parsed as part of the qt date string parser:

http://doc.qt.nokia.com/4.7-snapshot/qtwebkit-bridge.html#date-time http://doc.qt.nokia.com/latest/qt.html#DateFormat-enum

Comment #3

Posted on Aug 10, 2011 by Quick Rabbit

Those two links are about QtWebKit bridge and Qt's own date format. That has nothing to do with the date parsing in JavaScript (totally separated code).

Comment #4

Posted on Aug 4, 2012 by Quick Rabbit

The QtWebKit you are using is no longer available at git://gitorious.org/qtwebkit/qtwebkit.git. But webkit 1.9.5 already fix the issue http://trac.webkit.org/browser/releases/WebKitGTK/webkit-1.9.5/Source/WTF/wtf/DateMath.cpp#L536

Comment #5

Posted on Sep 7, 2012 by Happy Rabbit

Comment deleted

Comment #6

Posted on Sep 7, 2012 by Happy Rabbit

This is still a problem with PhantomJS 1.6.1. Just bitten by it... Steps to reproduce: $ phantomjs

new Date('2012-09-07') "Invalid Date" All other browsers understand the date in shortened ISO8601 format. The workaround is to add "T00:00:00Z": new Date('2012-09-07T00:00:00Z') "2012-09-07T00:00:00.000Z" but be aware that it may change the date depending on your timezone.

Thanks as always for your excellent work, Ariya.

Comment #7

Posted on Oct 10, 2012 by Quick Rabbit

Pull request: https://github.com/ariya/phantomjs/pull/326

Comment #8

Posted on Nov 3, 2012 by Quick Rabbit

Fix parsing dates in ISO8601 format. https://github.com/ariya/phantomjs/commit/35c1971595

Comment #9

Posted on Mar 16, 2013 by Happy Horse

This issue has been moved to GitHub: https://github.com/ariya/phantomjs/issues/10187

Status: Fixed

Labels:
Type-Defect Priority-Medium Milestone-Release1.8 Component-Logic Domain-WebKit