mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-11 03:46:46 +03:00
Searching bug in datetime
This commit is contained in:
parent
e99c6a1db3
commit
8b9e2332db
|
@ -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")
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user