mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
- hass_state: use httpx (async) instead of undefined requests/asyncio.TimeoutError - prompt_manager: call sync get_weather directly on executor thread; drop lunar plumbing - register: repopulate module_func_map so module-level plugins expand to functions - whisper/kokoro: run blocking transcribe/HTTP calls via asyncio.to_thread - edge TTS: re-apply volume/rate/pitch percentage params; elevenlabs: pass voice_settings - add GeminiVLLM provider (google-genai) backing the GeminiVLLM config entry - get_news: dedicated NEWS cache (15m) and live Western RSS defaults; drop dead newsnow branch - play_music: return Action.RECORD so playback turns enter dialogue history - ota_handler: default timezone_offset 0; config: prompt_template, HA entities, voice, language - agent-base-prompt.txt: rebuilt from upstream engineered English baseline - tests: drop shims/expectations for providers removed by the western provider set
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
"""
|
|
Time utility module
|
|
Provides unified time retrieval functionality
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
WEEKDAY_MAP = {
|
|
"Monday": "Monday",
|
|
"Tuesday": "Tuesday",
|
|
"Wednesday": "Wednesday",
|
|
"Thursday": "Thursday",
|
|
"Friday": "Friday",
|
|
"Saturday": "Saturday",
|
|
"Sunday": "Sunday",
|
|
}
|
|
|
|
|
|
def get_current_time() -> str:
|
|
"""
|
|
Get current time string (format: HH:MM)
|
|
"""
|
|
return datetime.now().strftime("%H:%M")
|
|
|
|
|
|
def get_current_date() -> str:
|
|
"""
|
|
Get today's date string (format: YYYY-MM-DD)
|
|
"""
|
|
return datetime.now().strftime("%Y-%m-%d")
|
|
|
|
|
|
def get_current_weekday() -> str:
|
|
"""
|
|
Get today's weekday
|
|
"""
|
|
now = datetime.now()
|
|
return WEEKDAY_MAP[now.strftime("%A")]
|
|
|
|
|
|
def get_current_date_formatted() -> str:
|
|
"""
|
|
Get current date in a more readable format
|
|
"""
|
|
try:
|
|
now = datetime.now()
|
|
return now.strftime("%B %d, %Y")
|
|
except Exception:
|
|
return "Failed to get date"
|
|
|
|
|
|
def get_current_time_info() -> tuple:
|
|
"""
|
|
Get current time information
|
|
Returns: (current time string, today's date, today's weekday, formatted date)
|
|
"""
|
|
current_time = get_current_time()
|
|
today_date = get_current_date()
|
|
today_weekday = get_current_weekday()
|
|
formatted_date = get_current_date_formatted()
|
|
|
|
return current_time, today_date, today_weekday, formatted_date
|