Skip to content

Commit

Permalink
[Mod] 调整时间戳的时区处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Jun 21, 2021
1 parent 731f351 commit 0cf5a6d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions vnpy_bybit/bybit_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def on_failed(self, status_code: int, request: Request) -> None:
data: dict = request.response.json()
error_msg: str = data["ret_msg"]
error_code: int = data["ret_code"]

msg = f"请求失败,状态码:{request.status},错误代码:{error_code}, 信息:{error_msg}"
self.gateway.write_log(msg)

Expand Down Expand Up @@ -1951,10 +1951,9 @@ def generate_datetime(timestamp: str) -> datetime:
dt: datetime = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
else:
dt: datetime = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ")

# dt: datetime = dt.replace(tzinfo=utc)
# dt: datetime = CHINA_TZ.normalize(dt.astimezone(CHINA_TZ))
return CHINA_TZ.localize(dt)

dt = utc.localize(dt)
return dt.astimezone(CHINA_TZ)


def generate_datetime_2(timestamp: int) -> datetime:
Expand Down

0 comments on commit 0cf5a6d

Please sign in to comment.