I believe json doesn't do this by default for at least a couple of
reasons

a) the solution would be programming language/version/application
specific
b) you can't differentiate strings from dates as json has no metadata
on it's fields
c) you'd have to stick to a RFC style complicated date parser to avoid
regional (=date format) problems

I actually made a patch for this myself, but it's much more cludgy
(that's why I didn't post it here), in my solution made the field look
like TIMESTAMP#TZ and added a #DATE to the key name (since I load it,
too, a hook removes this and recreates the date object transparently).

On Jan 14, 7:39 pm, Timothy Farrell <[email protected]> wrote:
> Yes, it works for date but it does not work for time.  I'm not sure how
> this would look implemented into web2py.  (You should read the page more
> thoroughly.)
>
> -Tim
>
>
>
> mdipierro wrote:
> > fantastic. can you email me a patch?
> > does it work for date and time too?
>
> > On Jan 14, 11:35 am, Timothy Farrell <[email protected]> wrote:
>
> >> BAM!
>
> >>https://mdp.cti.depaul.edu/web2py_wiki/default/wiki/JSONdatetime
>
> >> carlo wrote:
>
> >>> Thank you Tim, I am looking forward to it.
>
> >>> carlo
>
> >>> On 14 Gen, 18:18, Timothy Farrell <[email protected]> wrote:
>
> >>>> That's funny, I just dealt with this issue yesterday.  I'll put a tip on
> >>>> the wiki and link it.
>
> >>>> -tim
>
> >>>> carlo wrote:
>
> >>>>> I had this problem trying to serialize a (SQLite) date field with
> >>>>> simplejson  through "js.dumps(mydata)" :
>
> >>>>> File "C:\Python25\web2py\gluon\contrib\simplejson\encoder.py", line
> >>>>> 332, in default
> >>>>>     raise TypeError("%r is not JSON serializable" % (o,))
> >>>>> TypeError: datetime.date(2009, 1, 14) is not JSON serializable
>
> >>>>> It seems something similar happened in Django:
>
> >>>>>http://code.djangoproject.com/ticket/2460
>
> >>>>> Is there any workaround?
>
> >>>>> carlo
>
> >>>> --
> >>>> Timothy Farrell <[email protected]>
> >>>> Computer Guy
> >>>> Statewide General Insurance Agency (www.swgen.com)
>
> >> --
> >> Timothy Farrell <[email protected]>
> >> Computer Guy
> >> Statewide General Insurance Agency (www.swgen.com)
>
> --
> Timothy Farrell <[email protected]>
> Computer Guy
> Statewide General Insurance Agency (www.swgen.com)
--~--~---------~--~----~------------~-------~--~----~
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