示例#1
0
文件: base.py 项目: dgerena/SSL
    def _DATETIME_to_python(self, value, dsc=None):
        """Connector/Python always returns naive datetime.datetime

        Connector/Python always returns naive timestamps since MySQL has
        no time zone support. Since Django needs non-naive, we need to add
        the UTC time zone.

        Returns datetime.datetime()
        """
        if not value:
            return None
        dt = MySQLConverter._DATETIME_to_python(self, value)
        if settings.USE_TZ and timezone.is_naive(dt):
            dt = dt.replace(tzinfo=timezone.utc)
        return dt
示例#2
0
    def _DATETIME_to_python(self, value, dsc=None):
        """Connector/Python always returns naive datetime.datetime

        Connector/Python always returns naive timestamps since MySQL has
        no time zone support. Since Ohm needs non-naive, assume all datetimes in database are in UTC
        then convert to Pacific Time

        Returns datetime.datetime()
        """
        if not value:
            return value

        dttm = MySQLConverter._DATETIME_to_python(self, value)
        if not dttm:
            return dttm

        if is_naive(dttm):
            dttm = db_timestamp_to_pacific_datetime(dttm)
        return dttm