As Iceberg said I have no evidence of Json supporting datetime
objects.

I usually convert my datetime objects into string before invoking the
callback: if the data returned by the callback function go into HTML
pages you have no problem to get a string returned by your callback.

When I need to get back a datetime object I usually pass the string to
the datetime.strptime() method, I do not know if this is the best way
but it is working if you need, for example, a datetime object saved in
SQLite databases.

carlo

On 4 Mag, 08:40, Iceberg <[email protected]> wrote:
> Mmm, I happened to meet same problem. Sure it is not a web2py issue,
> not even a python issue. It is mainly because JSON standard does not
> define how to handle date and time.
>  http://www.json.org/index.html
>
> Anyway, encoding datetime is easy. There are even simpler ways here.
>  http://stackoverflow.com/questions/455580/json-datetime-between-pytho...
>
> The difficult part is how to decode the json string back to a datetime
> object. If anyone who knows any lib doing so, in a de-facto standard
> way, please let me know. Thanks!
>
> On May4, 1:24pm, weheh <[email protected]> wrote:
>
> > simplejson.dumps(x) should support datetime. Same goes for
> > simplejson.loads(y).
>
> > Having worked around this limitation within gluon.contrib.simplejson I
> > am convinced this is going to be a pain every time I work with
> > datetime and somebody else's website. I'm interfacing a calendar app
> > to another website. Everything in python is done with datetime, not
> > string. So I convert once just before calling dumps but it just took
> > me around 10 minutes or more to write a set of nested loops to handle
> > my output data structure. I'm pretty sure I'm going to have to do
> > something similar again in a couple/few more places. I'll be faster
> > the next time, but still, uggh.
>
> On Apr30, 9:18pm, carlo <[email protected]> wrote:
>
> > I had the same problem: my Json data were going into an Html form.
>
> > I solved simply converting my date object into string with str()
> > before dumping Json data: I do not know if this is suitable for your
> > case
>
> > carlo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to