This
SQLField('datum',type='date',requires=[IS_DATE(str(T('%Y-%m-
%d'))),IS_NOT_EMPTY()])
should be
SQLField('datum',type='date',requires=IS_DATE(str(T('%Y-%m-%d'))))
other than that it is fine.
The main problem is here:
> fromdate=request.vars.datum
> todate=IS_DATE()(fromdate)[0]+datetime.timedelta(days=int(request.vars.dagen))
since IS_DATE is not being passer the format string so fromdate does
not pass valudation and it id does not it return (fromdate,error)
where fromdate is the original string, hence IS_DATE()(fromdate)[0]
is string and cannot be concatenated with timedelta. It should be
todate=form.vars.datum+datetime.timedelta(days=int(form.vars.dagen))
executed ONLY is the accept is true (validation passed hence
request.vars.datum is cinverterd to date object and stored in
form.vars.datum)
It depends on the logic, i.e. the order in which those functions are
executed.
On Apr 15, 3:26 am, [email protected] wrote:
> Massimo,
>
> I had to add:
>
> T.force('en-nl')
>
> to db.py to get the strings translated.
>
> This introduced the following error:
>
> File "/Library/Python/2.5/site-packages/web2pyfitwise/applications/
> core/controllers/eventlist.py", line 25, in byplace
> todate=IS_DATE()(fromdate)[0]+datetime.timedelta(days=int
> (request.vars.dagen))
> TypeError: cannot concatenate 'str' and 'datetime.timedelta' objects
>
> The code in the function reads like:
>
> fromdate=request.vars.datum
> todate=IS_DATE()(fromdate)[0]+datetime.timedelta(days=int
> (request.vars.dagen))
>
> where, datum refers to the field that has been translated:
>
> SQLField('datum',type='date',requires=[IS_DATE(str(T('%Y-%m-%d'))),
> IS_NOT_EMPTY()])
>
> I expected this error to occur:
>
> >> What are the consequences of these two options for these line of code:
> >> fromdate=request.vars.datum
> > >todate=IS_DATE()(fromdate)[0]+datetime.timedelta(days=int
> >> (request.vars.dagen))
> >> Here todate should be calculated as: fromdate + days = todate
> >> It worked when I used the YYYY-MM-DD format, however, now that I
> >> changed the format to DD-MM-YYYY I expect it to break.
> >It will not break. The date as stored by the system is always
> >independent by the way you choose to represent it when printed.
>
> I hope you can provide me with a solution to solve this problem.
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---