[PATCH stable] hgweb: fix dynamic date calculation not working under Safari

Laurens Holst laurens.nospam at grauw.nl
Mon Oct 24 18:22:29 CDT 2011


Op 24-10-2011 21:02, Brodie Rao schreef:
> While Chrome, Firefox, and IE 6+ support the current date format being
> passed to Date(), Safari doesn't:
>
>> new Date('Mon Oct 24 13:58:01 2011 +0200')
> Invalid Date
>
> However, the rfc3339date format does work:
>
>> new Date('2011-10-24T13:58:01+02:00')
> Mon Oct 24 2011 04:58:01 GMT-0700 (PDT)
>
> This change adds a new data-date attribute to all age/date elements in
> each theme. If process_dates() sees an age element with that
> attribute, it'll prefer it over using the element's text content.
>
> Tested in IE 6, Safari 5.1.1, Google Chrome 15, and Firefox 6.0.1.

Hi Brodie,

ISO dates are a relatively new addition to JavaScript in ECMAScript 5 
(section 15.9.3.2) and will not work in all browsers. I can’t give you a 
breakdown, but amongst others (iirc) I know that the iOS JavaScript 
implementation can not parse it. To be honest I thought IE would have a 
problem with it as well (but I guess not).

Either way, the most compatible date parsing format is RFC822 used in ES3:

   Mon, 25 Dec 1995 13:30:00 GMT+0430

I would recommend you use this one.

See:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse

~Laurens

-- 
~~ Ushiko-san! Kimi wa doushite, Ushiko-san nan da!! ~~
Laurens Holst, developer, Utrecht, the Netherlands
Website: www.grauw.nl. Working @ www.roughcookie.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4332 bytes
Desc: S/MIME cryptografische ondertekening
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20111025/75901721/attachment.bin>


More information about the Mercurial-devel mailing list