first time I hear someone having 2.5 issues, nice!
let's see if we can clear them up....
1.
The plugin basically works invoking a nice js library that does its best to
determine client-side what timezone the user is in.
This info is POSTed to web2py, and stored in the user session.
Since the "auto-determination" can only be done on client-side, you NEED to
use that piece of code (fast_tz_detector) in AT LEAST one page. If you
don't know where the user lands initially, well, it's an architectural
problem of the app. call it with ajax in every page, redirect the user
there and then on the home page if session.plugin_timezone_tz is not there
already, you name it.
The important bit to grasp is that if you don't use fast_tz_detector, you
don't have the session.plugin_timezone_tz filled.
fast_tz_detector just appends the javascript needed plus a snippet that
fills the session value.
Without it, you NEED to guess yourself or make the user choose its
preferred timezone explicitely (using, e.g., tz_nice_detector_widget).
2.
it's definitely dependant on your custom represent. It's the IS_DATE(TIME)
validator that, set up with the timezone info, does "the math" and when
called for representation, displays the right value. If you want to make
your own representation, you need to do the
same math.
"The math" is pretty straightforward, given that "d" is the utc datetime
value, is
"d.replace(tzinfo=pytz.UTC).astimezone(pytz.timezone(user_timezone))"
2.1
web2py has a pretty extensive internationalization support, and it includes
date formatting. IS_DATETIME and IS_DATE both take a "format" parameter
that correctly represents the date as specified in the format. the default
value for IS_DATETIME is "T('%Y-%m-%d %H:%M:%S')" . the T is the
internationalization support, so if you set in the relevant language file
to be %m-%d %H:%M, it'll be shown throughout all the app. If you don't want
to leverage internationalization and just set a fixed representation, use
format='%m-%d %H:%M', without any T involved .
BTW: Fixing 2.1 will effectively eliminate the 2. issue: you won't need any
custom represent.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.