Skip to content

Commit

Permalink
fix: apply timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroam committed Nov 5, 2024
1 parent 62fd984 commit be495ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ repos:
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [types-requests]
additional_dependencies: [types-requests, types-pytz]
args: [--config-file=mypy.ini]
exclude: ^tests/
7 changes: 5 additions & 2 deletions kispy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile
from datetime import datetime

import pytz
import requests
from pydantic import BaseModel, Field

Expand All @@ -20,7 +21,8 @@ class Token(BaseModel):
access_token_token_expired: datetime = Field(description="액세스 토큰 만료일시")

def is_expired(self) -> bool:
return datetime.now() > self.access_token_token_expired
kst = pytz.timezone("Asia/Seoul")
return datetime.now(kst) > self.access_token_token_expired


class KisAuth:
Expand Down Expand Up @@ -56,10 +58,11 @@ def _get_token(self) -> Token:
"appsecret": self.app_secret,
},
)
kst = pytz.timezone("Asia/Seoul")
access_token_token_expired = datetime.strptime(
resp.json["access_token_token_expired"],
"%Y-%m-%d %H:%M:%S",
)
).replace(tzinfo=kst)
return Token(
token_type=resp.json["token_type"],
access_token=resp.json["access_token"],
Expand Down

0 comments on commit be495ee

Please sign in to comment.