Thank you Niphold Thanks for the explanation: My specific individual problem was that it took me a while to find out where to inject the tz script that I generate (in my case in the index() function). Since the index function is the first page in my application I just had to add {{=tz}} in the header of the index.html. Hopefully this will help others for faster understanding. Thanks also for the solution for the last 1.5 :-)
Best Regards Itamar Cohen Picatek Ahornvej 27 DK-7700 Thisted Denmark www.picatek.dk i...@picatek.dk T: +45 97 91 07 82 M:+45 29 89 07 82 On 24 September 2015 at 20:56, Niphlod <niph...@gmail.com> wrote: > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/jIEUIb8wxtg/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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/d/optout.