def date(context, value, format=None, tz=None):
    handler = context["handler"]
    if tz is not None:
        timezone = get_timezone(tz)
    else:
        timezone = handler.timezone

    if is_naive(value):
        value = make_aware(value, get_default_timezone(handler.application))

    # TODO: full django like formate subsystem
    return as_localtime(value, timezone)
def date(context, value, format=None, tz=None):
    handler = context["handler"]
    if tz is not None:
        timezone = get_timezone(tz)
    else:
        timezone = handler.timezone

    if is_naive(value):
        value = make_aware(value, get_default_timezone(handler.application))

    # TODO: full django like formate subsystem
    return as_localtime(value, timezone)
Beispiel #3
0
 def activate_timezone(self, timezone_name):
     self.session["webtools_timezone"] = timezone_name
     self._timezone = get_timezone(timezone_name)
Beispiel #4
0
 def get_user_timezone(self):
     if "webtools_timezone" in self.session:
         return get_timezone(self.session["webtools_timezone"])
     return get_timezone(self.application.conf.DEFAULT_TZ)