From 5832111f461cabaafa8076c1e78b385f7760e141 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 29 Dec 2022 16:18:16 +0100 Subject: [PATCH] Replace dependency "chrono" with "time" Signed-off-by: Matthias Beyer --- Cargo.toml | 6 +++--- src/entities/account.rs | 5 +++-- src/entities/notification.rs | 5 +++-- src/entities/status.rs | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9fdc50d..ee5bc91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,9 +36,9 @@ features = ["v4"] version = "0.4" features = ["kv_unstable", "serde", "std", "kv_unstable_serde", "kv_unstable_std"] -[dependencies.chrono] -version = "0.4" -features = ["serde"] +[dependencies.time] +version = "0.3" +features = ["parsing", "serde", "formatting"] [dependencies.envy] version = "0.4" diff --git a/src/entities/account.rs b/src/entities/account.rs index bac9b79..3a82f17 100644 --- a/src/entities/account.rs +++ b/src/entities/account.rs @@ -1,12 +1,12 @@ //! A module containing everything relating to a account returned from the api. use crate::status_builder; -use chrono::prelude::*; use serde::{ de::{self, Deserializer, Unexpected}, Deserialize, Serialize, }; use std::path::PathBuf; +use time::{serde::iso8601, OffsetDateTime}; /// A struct representing an Account. #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] @@ -18,7 +18,8 @@ pub struct Account { /// URL to the avatar static image (gif) pub avatar_static: String, /// The time the account was created. - pub created_at: DateTime, + #[serde(with = "iso8601")] + pub created_at: OffsetDateTime, /// The account's display name. pub display_name: String, /// The number of followers for the account. diff --git a/src/entities/notification.rs b/src/entities/notification.rs index e3ede9f..d09c1d7 100644 --- a/src/entities/notification.rs +++ b/src/entities/notification.rs @@ -1,8 +1,8 @@ //! Module containing all info about notifications. use super::{account::Account, status::Status}; -use chrono::prelude::*; use serde::{Deserialize, Serialize}; +use time::{serde::iso8601, OffsetDateTime}; /// A struct containing info about a notification. #[allow(clippy::derive_partial_eq_without_eq)] @@ -14,7 +14,8 @@ pub struct Notification { #[serde(rename = "type")] pub notification_type: NotificationType, /// The time the notification was created. - pub created_at: DateTime, + #[serde(with = "iso8601")] + pub created_at: OffsetDateTime, /// The Account sending the notification to the user. pub account: Account, /// The Status associated with the notification, if applicable. diff --git a/src/entities/status.rs b/src/entities/status.rs index 0a7c94c..89414cd 100644 --- a/src/entities/status.rs +++ b/src/entities/status.rs @@ -2,8 +2,8 @@ use super::prelude::*; use crate::{entities::card::Card, status_builder::Visibility}; -use chrono::prelude::*; use serde::{Deserialize, Serialize}; +use time::{serde::iso8601, OffsetDateTime}; /// A status from the instance. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -28,7 +28,8 @@ pub struct Status { /// (remote HTML already sanitized) pub content: String, /// The time the status was created. - pub created_at: DateTime, + #[serde(with = "iso8601")] + pub created_at: OffsetDateTime, /// An array of Emoji pub emojis: Vec, /// The numbef or replies to this status.