Bug #2304

duktape returns 'Invalid date' while converting date string (spidermonkey and other engines do that properly)

Added by Leonid Protasov over 6 years ago. Updated over 6 years ago.

Status:FixedStart date:10/30/2014
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

100%

Category:API
Target version:4.8
Found in version:Latest BE Platform:Linux

Description

var now='Thu, 30 Oct 2014 22:00:49 GMT'
showtime.print(+new Date(now)); - fails on duktape and is ok on spidermonkey

History

#1 Updated by Leonid Protasov over 6 years ago

Tried on http://jsfiddle.net/6rc8kdta/ works ok:

var now='Thu, 30 Oct 2014 22:00:49 GMT';
alert(+new Date(now));

#2 Updated by Leonid Protasov over 6 years ago

  • Subject changed from duktape fails to convert date from google while spidermonky has no issues on that to duktape returns 'Invalid date' while converting date string (spidermonkey and other engines do that properly)

#3 Updated by Leonid Protasov over 6 years ago

Well there is something wrong with Showtime.parseTime:

In Spidermonkey it does:

JS [DEBUG]: Google time: Mon, 10 Nov 2014 06:17:10 GMT
JS [DEBUG]: System time: Mon Nov 10 2014 08:17:10 GMT+0200 (EEST) Timestamp: 1415600230000

In duktape:

divan.tv [DEBUG]: Google time: Mon, 10 Nov 2014 06:17:24 GMT
divan.tv [DEBUG]: System time: 2014-11-10 08:17:24.000+02:00 Timestamp: 1415600244000

As we see timestamp difference is very big. So I assume parseTime does something getTime of duktape doesn't like...

The code I test it on is:

        var now = showtime.httpReq("http://google.com", { method: 'HEAD' }).headers.Date;
        showtime.trace('Google time: ' + now);
        if (typeof Duktape != 'undefined')
            now = new Date(Showtime.parseTime(now));
        else
            now = new Date(now);

        showtime.trace('System time: ' + now + ' Timestamp: ' + now.getTime());

#4 Updated by Leonid Protasov over 6 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Managed to apply the fix. So I'm closing this at least for 4.8...

Also available in: Atom PDF