ai_invest/backend/airflow/dags/plugins/utils/common_datetime.py

23 lines
588 B
Python
Raw Permalink Normal View History

import pendulum
from datetime import datetime, timezone, timedelta
TIMEZONE_KST = timezone(timedelta(hours=9))
class CommonDatetime:
@staticmethod
def make_kst_timezone():
return pendulum.timezone("Asia/Seoul")
@staticmethod
def make_datetime_kst_from_ts(ts: str) -> datetime:
return datetime.fromisoformat(ts).astimezone(TIMEZONE_KST)
# DATETIME으로 입력받고 한국 시간적용된 시간으로 리턴턴
@staticmethod
def make_datetime_kst_from_datetime(dt: datetime) -> datetime:
return dt.astimezone(TIMEZONE_KST)