From: Simon Tatham Date: Sat, 23 Dec 2023 10:23:57 +0000 (+0000) Subject: Got most of the dates, but what about last_status_at? X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=e529893b8eb98674b73a3798cdd451e93462348f;p=mastodonochrome.git Got most of the dates, but what about last_status_at? --- diff --git a/Cargo.toml b/Cargo.toml index 5f07ea3..10b6e22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +chrono = { version = "0.4.31", features = ["serde"] } crossterm = "0.27.0" html2text = "0.9.0" reqwest = { version = "0.11.23", features = ["blocking"] } diff --git a/src/main.rs b/src/main.rs index caf9c6a..17faa09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use chrono::{DateTime,Utc}; use serde::{Deserialize, Serialize}; use serde_json::Result; use std::boxed::Box; @@ -7,7 +8,7 @@ use std::option::Option; struct AccountField { name: String, value: String, - verified_at: Option, // FIXME: date + verified_at: Option>, } #[derive(Serialize, Deserialize, Debug)] @@ -32,8 +33,8 @@ struct Account { moved: Option>, suspended: Option, limited: Option, - created_at: String, // FIXME: sort out dates! - last_status_at: String, // FIXME: sort out dates! + created_at: DateTime, + // last_status_at: Option>, // FIXME: server can send just "2023-12-20" statuses_count: u64, followers_count: u64, following_count: u64, @@ -49,7 +50,7 @@ struct Application { struct Status { id: String, uri: String, - created_at: String, // FIXME: sort out dates! + created_at: DateTime, account: Account, content: String, visibility: String, // FIXME: enum @@ -71,7 +72,7 @@ struct Status { // card: Option, language: Option, text: Option, - edited_at: Option, // FIXME actually a date + edited_at: Option>, favourited: Option, reblogged: Option, muted: Option, @@ -81,12 +82,6 @@ struct Status { } fn main() { - let body = reqwest::blocking::get( - "https://hachyderm.io/api/v1/accounts/111096602447828617") - .unwrap().text().unwrap(); - let acc: Account = serde_json::from_str(&body).unwrap(); - dbg!(acc); - let body = reqwest::blocking::get( "https://hachyderm.io/api/v1/statuses/111602135142646031") .unwrap().text().unwrap();