Searching bug in datetime

This commit is contained in:
M1ha 2019-06-28 13:10:29 +05:00
parent e99c6a1db3
commit 8b9e2332db
2 changed files with 3 additions and 2 deletions

View File

@ -54,6 +54,7 @@ def format_datetime(dt, timezone_offset=0, day_end=False, db_alias=None):
# Dates in ClickHouse are parsed in server local timezone. So I need to add server timezone
server_dt = dt - datetime.timedelta(minutes=timezone_offset - get_tz_offset(db_alias))
print(dt, timezone_offset, get_tz_offset(db_alias))
return server_dt.strftime("%Y-%m-%d %H:%M:%S")

View File

@ -27,8 +27,8 @@ class FormatDateTimeTest(TestCase):
:param dt: Объект datetime.datetime
:return: Строковый ожидаемый результат
"""
moscow_minute_offset = dt.utcoffset().total_seconds() / 60
zone_h, zone_m = abs(int(moscow_minute_offset / 60)), int(moscow_minute_offset % 60)
minute_offset = dt.utcoffset().total_seconds() / 60
zone_h, zone_m = abs(int(minute_offset / 60)), int(minute_offset % 60)
return local_dt_str(dt - datetime.timedelta(hours=zone_h, minutes=zone_m))