Skip to main content

max / goingson

1.4 KB · 37 lines History Blame Raw
1 //! Application metadata commands.
2 //!
3 //! Exposes static, app-level information to the frontend. The changelog is
4 //! embedded at compile time via `include_str!` so the "What's New" dialog can
5 //! surface release notes after an OTA update without shipping a separate
6 //! resource file or reading from disk at runtime.
7
8 use tracing::instrument;
9
10 /// The project changelog, baked into the binary at build time.
11 const CHANGELOG: &str = include_str!("../../../CHANGELOG.md");
12
13 /// Parse a free-text date ("tomorrow", "friday 3pm", "dec 25", ISO) into a
14 /// local `YYYY-MM-DDTHH:MM` string, or `None` if unrecognized.
15 ///
16 /// This is the single source of truth for date-field parsing; the frontend
17 /// calls it instead of duplicating the grammar in JavaScript. Resolution is
18 /// relative to the machine's local wall-clock time.
19 #[tauri::command]
20 #[instrument]
21 pub async fn parse_natural_date(input: String) -> Option<String> {
22 let now = chrono::Local::now().naive_local();
23 goingson_core::parse_natural_date(&input, now)
24 .map(|dt| dt.format("%Y-%m-%dT%H:%M").to_string())
25 }
26
27 /// Return the raw `CHANGELOG.md` contents.
28 ///
29 /// The frontend parses out the section for the freshly-installed version and
30 /// renders it in the "What's New" dialog. Infallible — the changelog is part
31 /// of the binary.
32 #[tauri::command]
33 #[instrument]
34 pub async fn get_changelog() -> String {
35 CHANGELOG.to_string()
36 }
37