diff --git a/src/router/mod.rs b/src/router/mod.rs index 69fdca5..9e129eb 100644 --- a/src/router/mod.rs +++ b/src/router/mod.rs @@ -1,9 +1,11 @@ use axum::{Router, http::StatusCode, routing::get}; +use chrono::{NaiveDate, Utc}; pub fn init() -> Router { Router::new() .route("/", get(async || "root")) .route("/discord/member-count", get(get_member_count)) + .route("/days/community", get(get_days_since_community_formation)) } async fn get_member_count() -> (StatusCode, String) { @@ -15,3 +17,11 @@ async fn get_member_count() -> (StatusCode, String) { ), } } + +async fn get_days_since_community_formation() -> String { + let formation = NaiveDate::from_ymd_opt(2020, 6, 7).unwrap(); + let today = Utc::now().date_naive(); + let days = today.signed_duration_since(formation).num_days(); + + days.to_string() +}