On 2011-02-23 14:09:11 -0800, Mariano Mara said:
On 23.02.11 11:56, Daniel Holth wrote:
I use a module called python-dateutil for date stuff, but I just show
UTC everywhere.
No easy way to do the current user's time zone. You could consider
using the pyramid threadlocal API to make your own 'render in current
user's time zone' function.
+1 to python-dateutil: one of the most useful libraries out there, it
should be part of every dev arsenal.
BTW, it has methods for dealing with tz info [1].
[1]
http://niemeyer.net/python-dateutil#head-587bd3efc48f897f55c179abc520a34330ee0a62
I
combine pytz (dateutil is excellent, too,) with user preference
pre-populated by JavaScript timezone detection and optional "relative
times", which improve caching substantially.
E.g. you render UTC in your template and cache the result. A JS script
called "timeago" then finds all <time> tags (or the selector of your
choice, e.g. <span rel="time">) and converts them to realtime-updated
relative times e.g. "30 seconds ago". These are updated on the page
automatically, once per minute, without having to refresh.
By reducing the amount of dynamic information (times rendered in
different time zones) the pages can be etag cached far more easily.
— Alice.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en.