How to use the pytz.gae.pytz.timezone function in pytz

To help you get started, we’ve selected a few pytz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mihaip / streamspigot / app / datasources / twitterdisplay.py View on Github external
if user.utc_offset:
        timezone = pytz.FixedOffset(user.utc_offset/60)
        # pytz FixedOffset instances return None for dst(), but then
        # astimezone() complains, so we just pretend like the DST offset
        # is always 0.
        timezone.dst = lambda self: datetime.timedelta(0)
        return timezone

    # Starting in April 2018*, Twitter no longer returns timezone data for users.
    # We default to PST since it's more likely to be accurate (at least for
    # Mihai) than UTC. The above code thus will never run, but keep it in case
    # Twitter changes their mind.
    #
    # * https://twittercommunity.com/t/upcoming-changes-to-the-developer-platform/104603
    return pytz.timezone('America/Los_Angeles')
github moraes / tipfy / source / tipfy / ext / i18n / __init__.py View on Github external
def get_tzinfo(timezone=None):
    """Returns a ``datetime.tzinfo`` object for the given timezone. This is
    called by :func:`format_datetime` and :func:`format_time` when a tzinfo
    is not provided.

    :param timezone:
        The timezone name from the Olson database, e.g.: 'America/Chicago'.
        If not set, uses the default configuration value.
    :return:
        A ``datetime.tzinfo`` object.
    """
    if timezone is None:
        timezone = get_config(__name__, 'timezone')

    if timezone not in _timezones:
        _timezones[timezone] = pytz.timezone(timezone)

    return _timezones[timezone]
github moraes / tipfy / extensions / tipfy.ext.db / tipfy / ext / db.py View on Github external
def validate(self, value):
        value = super(TimezoneProperty, self).validate(value)
        if value is None or hasattr(value, 'zone'):
            return value
        elif isinstance(value, basestring):
            return pytz.timezone(value)

        raise db.BadValueError("Property %s must be a pytz timezone or string."
            % self.name)
github rosskarchner / eventgrinder / museum / distlib / tipfy / ext / i18n.py View on Github external
def get_timezone(timezone=None):
    """Returns a ``datetime.tzinfo`` object for the given timezone. This is
    called by [[#format_datetime]] and [[#format_time]] when a tzinfo
    is not provided.

    :param timezone:
        The timezone name from the Olson database, e.g.: ``America/Chicago``.
        If not set, uses the default configuration value.
    :returns:
        A ``datetime.tzinfo`` object.
    """
    return pytz.timezone(timezone or get_config(__name__, 'timezone'))
github moraes / tipfy / source / tipfy / ext / db / __init__.py View on Github external
def validate(self, value):
        value = super(TimezoneProperty, self).validate(value)
        if value is None or hasattr(value, 'zone'):
            return value
        elif isinstance(value, basestring):
            return pytz.timezone(value)

        raise db.BadValueError("Property %s must be a pytz timezone or string."
            % self.name)
github moraes / tipfy / extensions / tipfy.ext.i18n / tipfy / ext / i18n.py View on Github external
def get_timezone(timezone=None):
    """Returns a ``datetime.tzinfo`` object for the given timezone. This is
    called by :func:`format_datetime` and :func:`format_time` when a tzinfo
    is not provided.

    * timezone:
        The timezone name from the Olson database, e.g.: 'America/Chicago'.
        If not set, uses the default configuration value.
    * Return:
        A ``datetime.tzinfo`` object.
    """
    return pytz.timezone(timezone or get_config(__name__, 'timezone'))
github moraes / tipfy / tipfyext / i18n.py View on Github external
def get_timezone(timezone=None):
    """Returns a ``datetime.tzinfo`` object for the given timezone. This is
    called by [[#format_datetime]] and [[#format_time]] when a tzinfo
    is not provided.

    :param timezone:
        The timezone name from the Olson database, e.g.: ``America/Chicago``.
        If not set, uses the default configuration value.
    :returns:
        A ``datetime.tzinfo`` object.
    """
    return pytz.timezone(timezone or Tipfy.app.get_config(__name__, 'timezone'))
github moraes / tipfy / extensions / tipfy.ext.db / tipfy / ext / db.py View on Github external
def make_value_from_datastore(self, value):
        return pytz.timezone(value)
github rosskarchner / eventgrinder / museum / distlib / tipfy / ext / db.py View on Github external
def validate(self, value):
        value = super(TimezoneProperty, self).validate(value)
        if value is None or hasattr(value, 'zone'):
            return value
        elif isinstance(value, basestring):
            return pytz.timezone(value)

        raise db.BadValueError("Property %s must be a pytz timezone or string."
            % self.name)