On 16 juin, 19:07, Nathan Naze <
nn...@google.com> wrote:
> On Wed, Jun 16, 2010 at 5:32 AM, Thomas Broyer <
t.bro...@gmail.com> wrote:
>
> > [OFF TOPIC]
>
> > On Jun 15, 10:35 pm, Nathan Naze <
nn...@google.com> wrote:
> >> On Tue, Jun 15, 2010 at 1:33 PM, Emil A Eklund <
e...@google.com> wrote:
>
> >> > On Tue, Jun 15, 2010 at 12:50, babbos <
bab...@gmail.com> wrote:
> >> >> Thank you Emil,
>
> >> >> So are there any plans on supporting it?
>
> >> > Yeah, we should probably add a method like goog.date.fromRfc822String.
>
> >> babbos, can you file an issue? Both Python and Closure don't have
> >> good support for RFC822 which annoys me when working with Atom feeds.
>
> > Er, Atom is only using a RFC3339/ISO8601/W3C-DateTime/XMLSchema-
> > DateTime compatible format. (actually a subset of RFC3339 which
> > happens to also be a subset of the other 3)
> > Seehttp://
tools.ietf.org/html/rfc4287#section-3.3
>
> Yes, you're right. I don't have the RFC numbers memorized, nor am I an
> expert in the area. I just know Atom's preferred format can be hard
> to parse in Python. Regardless, an implementation would be useful in
> Closure (of both, I guess).
>
>
http://en.wikipedia.org/wiki/Atom_(standard)#Date_formats
If you're lazy, this regex is enough to parse an Atom-formatted date:
/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d*)?(Z|([+-])
(\d{2}):(\d{2}))/
Usable in both Python and JavaScript, you then just have to pass the
matched groups to some Date constructor (just beware of the timezone,
particularly in JS, but I guess Closure already deals with this)
Also have a look at the Universal Feed Parser and feedvalidator
projects (for both RSS and Atom, parsing only), both written in
Python:
http://feedparser.org/docs/date-parsing.html
http://code.google.com/p/feedvalidator/source/browse/trunk/feedvalidator/src/feedvalidator/validators.py#479