brawl-rs 0.1.0

A Rust wrapper for the Brawl Stars API
Documentation
#![doc = include_str!("../README.md")]

pub mod client;
pub mod data;
pub mod errors;
pub mod models;
pub mod prelude;

use chrono::{DateTime, NaiveDateTime, Utc};
pub use client::BrawlClient;
pub use errors::BrawlError;
use serde::Deserialize;

pub(crate) fn parse_date<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error>
where
    D: serde::Deserializer<'de>,
{
    let s = String::deserialize(deserializer)?;
    let naive = NaiveDateTime::parse_from_str(&s, "%Y%m%dT%H%M%S%.3fZ")
        .map_err(serde::de::Error::custom)?;

    let time = DateTime::<Utc>::from_naive_utc_and_offset(naive, Utc);

    Ok(time)
}