Rails gives you the possibility to include a field in your tables with
the date in wich a record has been updated: updated-at. Well, I can
access this filed via xml (I'm developing an Ajax application) so I
have it in plain text form and looks something like this:
2008-07-05T19:47:32+02:00
I would like to parse this text into a Javascript Date object like
this:
Date.parse('2008-07-05T19:47:32+02:00') // DOESN'T WORK
But before I resort to write (and then test) my own parser, I would
like to know if there's a built in parser for it in Javascript or in
some extern library or, at least, the name for this particular format
so I can Google it.
Rails gives you the possibility to include a field in your tables with
the date in wich a record has been updated: updated-at. Well, I can
access this filed via xml (I'm developing an Ajax application) so I
have it in plain text form and looks something like this:
2008-07-05T19:47:32+02:00
I would like to parse this text into a Javascript Date object like
this:
Date.parse('2008-07-05T19:47:32+02:00') // DOESN'T WORK
But before I resort to write (and then test) my own parser, I would
like to know if there's a built in parser for it in Javascript or in
some extern library or, at least, the name for this particular format
so I can Google it.
Thanks.
Hi Abel. If I were facing this dilemma, I would add a method on the
model that returns the date in the format that you need it:
def updated_at_js
updated_at.strftime(<some format>)
end
Then call to_xml like this:
p = Person.find_by_id(params[:id])
p.to_xml :methods => :updated_at_js
so the properly formatted date is included in the xml packet. Then just
use that one in your JS.