//! Application metadata commands. //! //! Exposes static, app-level information to the frontend. The changelog is //! embedded at compile time via `include_str!` so the "What's New" dialog can //! surface release notes after an OTA update without shipping a separate //! resource file or reading from disk at runtime. use tracing::instrument; /// The project changelog, baked into the binary at build time. const CHANGELOG: &str = include_str!("../../../CHANGELOG.md"); /// Parse a free-text date ("tomorrow", "friday 3pm", "dec 25", ISO) into a /// local `YYYY-MM-DDTHH:MM` string, or `None` if unrecognized. /// /// This is the single source of truth for date-field parsing; the frontend /// calls it instead of duplicating the grammar in JavaScript. Resolution is /// relative to the machine's local wall-clock time. #[tauri::command] #[instrument] pub async fn parse_natural_date(input: String) -> Option { let now = chrono::Local::now().naive_local(); goingson_core::parse_natural_date(&input, now) .map(|dt| dt.format("%Y-%m-%dT%H:%M").to_string()) } /// Return the raw `CHANGELOG.md` contents. /// /// The frontend parses out the section for the freshly-installed version and /// renders it in the "What's New" dialog. Infallible — the changelog is part /// of the binary. #[tauri::command] #[instrument] pub async fn get_changelog() -> String { CHANGELOG.to_string() }