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

Matt Mackall mpm at selenic.com
Tue Oct 25 11:26:36 CDT 2011


On Mon, 2011-10-24 at 21:23 -0700, Brodie Rao wrote:
> On Mon, Oct 24, 2011 at 4:22 PM, Laurens Holst <laurens.nospam at grauw.nl> wrote:
> > 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
> 
> I can definitely use the rfc822date filter instead.
> 
> Perhaps we could just use that for the text content instead of
> {date|date}. That'd also get rid of the need to have an extra
> attribute.

Sure.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list