Agridatalog / app /core /time_engine.py
Agridatalogia's picture
time and date
81d47a9
Raw
History Blame Contribute Delete
1.01 kB
from datetime import datetime
from typing import Tuple
class TimeEngine:
@staticmethod
def get_season() -> str:
"""Get current season based on month"""
month = datetime.now().month
if month in [12, 1, 2]:
return "winter"
elif month in [3, 4, 5]:
return "spring"
elif month in [6, 7, 8]:
return "summer"
else:
return "autumn"
@staticmethod
def get_time_of_day() -> str:
"""Get time of day for context"""
hour = datetime.now().hour
if hour < 12:
return "morning"
elif hour < 18:
return "afternoon"
else:
return "evening"
@staticmethod
def get_current_date() -> str:
"""Get current date (YYYY-MM-DD)"""
return datetime.now().strftime("%Y-%m-%d")
@staticmethod
def get_current_time() -> str:
"""Get current time (HH:MM)"""
return datetime.now().strftime("%H:%M")