Skip to content

Commit 52509eb

Browse files
Fix DST related errors, check for timezone support. Edit tox file.
[skip ci]
1 parent 790498d commit 52509eb

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

mssql/features.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
1919
has_select_for_update = True
2020
has_select_for_update_nowait = True
2121
has_select_for_update_skip_locked = True
22-
has_zoneinfo_database = False
2322
ignores_table_name_case = True
2423
ignores_quoted_identifier_case = True
2524
requires_literal_defaults = True
@@ -56,3 +55,9 @@ def supports_partial_indexes(self):
5655
@cached_property
5756
def supports_functions_in_partial_indexes(self):
5857
return self.connection.sql_server_version > 2005
58+
59+
@cached_property
60+
def has_zoneinfo_database(self):
61+
with self.connection.cursor() as cursor:
62+
cursor.execute("SELECT TOP 1 1 FROM sys.time_zone_info")
63+
return cursor.fetchone() is not None

mssql/operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _get_utcoffset(self, tzname):
3434
# no way to take DST into account at this point
3535
now = datetime.datetime.now()
3636
delta = zone.localize(now, is_dst=False).utcoffset()
37-
return delta.days * 86400 + delta.seconds
37+
return delta.days * 86400 + delta.seconds - zone.dst(now).seconds
3838

3939
def bulk_batch_size(self, fields, objs):
4040
"""

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
1212
git checkout $DJANGO_VERSION
1313
pip install -r tests/requirements/py3.txt
1414

15-
python tests/runtests.py --settings=testapp.settings --noinput --keepdb \
15+
python tests/runtests.py --settings=testapp.settings --noinput \
1616
aggregation \
1717
aggregation_regress \
1818
annotations \

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ whitelist_externals =
99
/bin/bash
1010

1111
commands =
12-
python manage.py test --keepdb
13-
python manage.py install_regex_clr test_default
12+
python manage.py test
1413
bash test.sh
1514

1615
deps =

0 commit comments

Comments
 (0)