Re: Dates in HTML 5

2007/6/28, Thomas Broyer:
>
> http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Ctitle%3ETests%20around%20the%20dates%3C/title%3E%0A%3Cscript%3Evar%20d%20%3D%20new%20Date%28%29%3B%3C/script%3E%0A%3Cdt%3Edocument.lastModified%0A%3Cdd%3E%3Cscript%3Edocument.write%28typeof%28document.lastModified%29%29%3C/script%3E%0A%3Cdd%3E%3Cscript%3Edocument.write%28document.lastModified%29%3C/script%3E%0A%3Cdd%3E%3Cscript%3Edocument.write%28new%20Date%28document.lastModified%29.toString%28%29%29%3C/script%3E%0A%3Cdt%3EtoString%0A%3Cdd%3E%3Cscript%3Edocument.write%28d.toString%28%29%29%3C/script%3E%0A%3Cdt%3EtoUTCString%0A%3Cdd%3E%3Cscript%3Edocument.write%28d.toUTCString%28%29%29%3C/script%3E%0A%3Cdt%3EtoLocaleString%0A%3Cdd%3E%3Cscript%3Edocument.write%28d.toLocaleString%28%29%29%3C/script%3E

Oops, sorry, forgot to update the results after changes to the test document:

> Firefox displays:
> document.lastModified
>     string
>     01/01/1970 00:00:00

    Thu Jan 01 1970 00:00:00 GMT+0100

> toString
>     Thu Jun 28 2007 20:13:57 GMT+0200
> toUTCString
>     Thu, 28 Jun 2007 18:13:57 GMT
> toLocaleString
>     jeudi 28 juin 2007 20:13:57
>
> IE7:
> document.lastModified
>     string
>     06/28/2007 20:14:15

    Thu Jun 28 20:24:00 UTC+0200 2007

> toString
>     Thu Jun 28 20:14:15 UTC+0200 2007
> toUTCString
>     Thu, 28 Jun 2007 18:14:15 UTC
> toLocaleString
>     jeudi 28 juin 2007 20:14:15
>
> Opera 9 (9.21):
> document.lastModified
>     string
>     January 1, 1970 GMT

    Thu, 01 Jan 1970 01:00:00 GMT+0100

> toString
>     Thu, 28 Jun 2007 20:19:42 GMT+0200
> toUTCString
>     Thu, 28 Jun 2007 18:19:42 GMT
> toLocaleString
>     28/06/2007 20:19:42
>
> In brief:
>  * Opera doesn't format document.lastModified as described in the spec today
>  * the implementations of toString, toUTCString and toLocaleString are
> all different

Forgot to say: this means not any page can be expected to work on all
three browsers without some additional work; so changing this
shouldn't break many pages.

-- 
Thomas Broyer

Received on Thursday, 28 June 2007 18:40:26 UTC