chiark / gitweb /
Got most of the dates, but what about last_status_at?
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 10:23:57 +0000 (10:23 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 10:23:57 +0000 (10:23 +0000)
Cargo.toml
src/main.rs

index 5f07ea3229c2b88a8435361dd38a3ff4401f14e5..10b6e229fe14fd8d4020508e9e8f8c99fda9d745 100644 (file)
@@ -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"] }
index caf9c6a699f82ac444a062375779f1f55d738b6b..17faa091c5e39f65818415eda9d748c82ab379b7 100644 (file)
@@ -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<String>, // FIXME: date
+    verified_at: Option<DateTime<Utc>>,
 }
 
 #[derive(Serialize, Deserialize, Debug)]
@@ -32,8 +33,8 @@ struct Account {
     moved: Option<Box<Account>>,
     suspended: Option<bool>,
     limited: Option<bool>,
-    created_at: String, // FIXME: sort out dates!
-    last_status_at: String, // FIXME: sort out dates!
+    created_at: DateTime<Utc>,
+    // last_status_at: Option<DateTime<Utc>>, // 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<Utc>,
     account: Account,
     content: String,
     visibility: String, // FIXME: enum
@@ -71,7 +72,7 @@ struct Status {
     // card: Option<PreviewCard>,
     language: Option<String>,
     text: Option<String>,
-    edited_at: Option<String>, // FIXME actually a date
+    edited_at: Option<DateTime<Utc>>,
     favourited: Option<bool>,
     reblogged: Option<bool>,
     muted: Option<bool>,
@@ -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();