This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use axum::{ | |
| async_trait, | |
| extract::{FromRequestParts, Request}, | |
| http::{request::Parts, StatusCode}, | |
| middleware::Next, | |
| routing::get, | |
| Router, | |
| }; | |
| #[derive(Debug)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::OnceLock; | |
| use chrono::{DateTime, Utc, format::StrftimeItems}; | |
| pub fn format_date(ts: DateTime<Utc>) -> String { | |
| static FORMAT: OnceLock<Vec<chrono::format::Item<'static>>> = OnceLock::new(); | |
| let items = FORMAT.get_or_init(|| StrftimeItems::new("%Y-%m-%d").collect()); | |
| ts.format_with_items(items.iter()).to_string() | |
| } | |
| /// Creates functions like the one above |
OlderNewer