I would lean toward #2 (your default seems reasonable). On Sunday, January 12, 2014 10:20:38 AM UTC-5, Massimo Di Pierro wrote: > > This is wrong in the code but for logical reason. IS_DATE should not > accept the timezone info. That is because unless you know a time of the > time, it is not possible to determine the date (and time of the day) in the > other timezone. This is reflected in the fact that datetime.date does not > take a timezone while datetime.datetime. > > There are two ways out: > 1) drop the IS_DATE(timezone) argument > 2) make an implicit assumption about the time of date (always 00:00:00?). > > Suggestions? > > On Sunday, 12 January 2014 06:00:15 UTC-6, Graham Robbins wrote: >> >> IS_DATE() formatter sets >> >> d = datetime.date(year, value.month, value.day) >> >> and if self.timezone is not None it calls d.replace with the tzinfo >> keyword, this results in the exception: >> >> File "/home/www-data/web2py/gluon/validators.py", line 2263, in formatter >> d = d.replace(tzinfo=utc).astimezone(self.timezone) >> TypeError: 'tzinfo' is an invalid keyword argument for this function >> >> >> Changing *d* to be a datetime.datetime instance returns the formatted >> date. >> >> The relevant field is: >> >> Field('deadline', 'date', requires=IS_DATE(timezone=pytz.timezone( >> 'America/Chicago'), >> format='%Y-%m-%d')) >> >> Should I be doing anything differently or does IS_DATE() need to be >> changed? >> >> Web2py: 2.8.2-stable+timestamp.2013.11.28.13.54.07 >> Python: 2.7.3 >> >
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.