mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
17 lines
375 B
Rust
17 lines
375 B
Rust
use chrono::NaiveDate;
|
|
use serde::Serializer;
|
|
|
|
const FORMAT: &str = "%Y-%m-%d";
|
|
|
|
pub mod naive_date_serializer {
|
|
use super::*;
|
|
|
|
pub fn serialize<S>(date: &NaiveDate, serializer: S) -> Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
let formatted_date = date.format(FORMAT).to_string();
|
|
serializer.serialize_str(&formatted_date)
|
|
}
|
|
}
|