- From: Thomas Broyer <t.broyer@gmail.com>
- Date: Thu, 28 Jun 2007 20:36:40 +0200
- To: public-html@w3.org
2007/6/27, Rob Marshall:
>
> I don't think it's safe to change document.lastModified, but I agree
> it's a terrible format. If it's still useful, perhaps a new attribute
> could be added that returns the last modified date as a DOMTimeStamp?
On the other hand, Opera 9 does not follow the format described in the spec.
Using the following document:
<!DOCTYPE html>
<title>Tests around the dates</title>
<script>var d = new Date();</script>
<dt>document.lastModified
<dd><script>document.write(typeof(document.lastModified))</script>
<dd><script>document.write(document.lastModified)</script>
<dd><script>document.write(new Date(document.lastModified).toString())</script>
<dt>toString
<dd><script>document.write(d.toString())</script>
<dt>toUTCString
<dd><script>document.write(d.toUTCString())</script>
<dt>toLocaleString
<dd><script>document.write(d.toLocaleString())</script>
You can test it here:
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
Firefox displays:
document.lastModified
string
01/01/1970 00:00:00
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
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
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
But most important: they're all capable of parsing their
document.lastModified into Date objects.
So how about:
* changing document.lastModified to a Date (or DOMTimeStamp)
* requiring that in ECMAScript bindings, toString() uses the
"MM/dd/yyyy HH:mm:ss" format (I know ECMAScript says the format is
implementation-dependent, but why couldn't we enforce it when used in
HTML?)
That way, document.write(document.lastModified) would yield the same
result in existing pages. And pages that use "new
Date(document.lastModified)" or "Date.parse(document.lastModified)"
also still work: this is enforced by ECMAScript. In other words, it
shouldn't break much things
--
Thomas Broyer
Received on Thursday, 28 June 2007 18:36:45 UTC