Refs #28373 -- Stopped setting tzinfo in typecast_timestamp().

Unnecessary since cef3f2d3c6. When
USE_TZ=True, conn_tznames is always passed to methods that use
typecast_timestamp(). Therefore, it can return naive datetimes.
This commit is contained in:
Sergey Fedoseev 2019-12-11 17:59:49 +05:00 committed by Mariusz Felisiak
parent ec12c37384
commit 88637064b3
1 changed files with 1 additions and 4 deletions

View File

@ -6,9 +6,7 @@ import logging
import time import time
from contextlib import contextmanager from contextlib import contextmanager
from django.conf import settings
from django.db.utils import NotSupportedError from django.db.utils import NotSupportedError
from django.utils.timezone import utc
logger = logging.getLogger('django.db.backends') logger = logging.getLogger('django.db.backends')
@ -170,11 +168,10 @@ def typecast_timestamp(s): # does NOT store time zone information
seconds, microseconds = seconds.split('.') seconds, microseconds = seconds.split('.')
else: else:
microseconds = '0' microseconds = '0'
tzinfo = utc if settings.USE_TZ else None
return datetime.datetime( return datetime.datetime(
int(dates[0]), int(dates[1]), int(dates[2]), int(dates[0]), int(dates[1]), int(dates[2]),
int(times[0]), int(times[1]), int(seconds), int(times[0]), int(times[1]), int(seconds),
int((microseconds + '000000')[:6]), tzinfo int((microseconds + '000000')[:6])
) )