JosephMajaseSithole / datejs

Automatically exported from code.google.com/p/datejs
0 stars 0 forks source link

[Firefox 3.1] toISOString returns "2008-10-21T15:06:11.324Z" instead of ""2008-10-21T15:06:11.324Z"" #54

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Note:
This issue relates to a nightly-build of Firefox 3.1, so it may not warrent
any action just yet since it could change again before the actual release
of 3.1. I'm posting it here though just in case though.

What steps will reproduce the problem?
1. Using Firefox 3.1b2pre (>= nightly build for 10-20-2008):
2. var d = new Date();
3. d.toISOString()

What is the expected output? What do you see instead?

expected:
~ ""2008-10-21T15:06:31Z""

see:
~ "2008-10-21T15:06:11.324Z"

What version of the product are you using? On what operating system?
Firefox 3.1b2pre (nightly build for 10-20-2008)

Please provide any additional information below.
This issue only started occurring in 3.1 as far as I know since the
10-20-2008 nightly build. The result of the switch is that some code used
to drop the extra quotation marks (slice(1,-1)) now drops important parts
of the date.

Original issue reported on code.google.com by keith.hu...@gmail.com on 21 Oct 2008 at 3:13

GoogleCodeExporter commented 8 years ago
Update 2009/06/22: Bug remains as of Firefox 3.5pre.

Original comment by keith.hu...@gmail.com on 22 Jun 2009 at 2:02

GoogleCodeExporter commented 8 years ago
I am also seeing this in FF3.5.  Does anyone have a workaround?

Original comment by joey.ski...@gmail.com on 6 Jul 2009 at 9:17

GoogleCodeExporter commented 8 years ago
A simple but not-so-elegant work-around is to just check for version 3.1+ of
Firefox,e.g.:

date = myDate.toISOString();
if (navigator.userAgent.search(/3\.[1-9]/) == -1)
    date = date.slice(1, -1);

Original comment by keith.hu...@gmail.com on 7 Jul 2009 at 12:15

GoogleCodeExporter commented 8 years ago
Update 2009/07/23:

Webkit also return single-quotes, so it looks like Firefox 3 (and older 
versions?)
are the only ones so far affected by this issue.

A simple solution to deal with either case is to simply remove all any quotation
marks, e.g.

myDate.toISOString().replace(/"/g,'');

If you want to keep one set of quotes:

myDate.toISOString().replace(/""/g,'"');

Any chance of fixing the behavior in Firefox 3.0?

Original comment by keith.hu...@gmail.com on 23 Jul 2009 at 2:41

GoogleCodeExporter commented 8 years ago
The .toISOString function was based on the JSON.org .toISOString function and 
is only
added by Datejs if the .toISOString function is not available natively. 

I just checked http://www.json.org/json.js (and http://www.json.org/json2.js) 
and it
appears they've once again changed the file and replaced the .toISOString 
function
with .toJSON.

The functionality and return result of .toJSON (formally .toISOString) appears 
to
have changed as well. 

I'm going to have to replace .toISOString. Maybe replace with our own 
.toJsonString()
and just completely avoid the JSON.org and native browser versions.

Original comment by geoff%co...@gtempaccount.com on 29 Jul 2009 at 7:03

GoogleCodeExporter commented 8 years ago
Using the MDN approved toISOString substitute now in my fork:

https://github.com/abritinthebay/datejs/

Original comment by darkcr...@gmail.com on 14 Sep 2013 at 1:01