time formatting
This commit is contained in:
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -131,6 +131,7 @@ dependencies = [
|
|||||||
"ratatui",
|
"ratatui",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"url",
|
"url",
|
||||||
@@ -348,6 +349,15 @@ version = "2.9.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deranged"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
||||||
|
dependencies = [
|
||||||
|
"powerfmt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -843,6 +853,12 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-conv"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.36.7"
|
version = "0.36.7"
|
||||||
@@ -970,6 +986,12 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "powerfmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
@@ -1379,6 +1401,25 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.3.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
|
||||||
|
dependencies = [
|
||||||
|
"deranged",
|
||||||
|
"num-conv",
|
||||||
|
"powerfmt",
|
||||||
|
"serde",
|
||||||
|
"time-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time-core"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinystr"
|
name = "tinystr"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ log = "0.4"
|
|||||||
env_logger = "0.10"
|
env_logger = "0.10"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
ratatui = "0.29.0"
|
ratatui = "0.29.0"
|
||||||
|
time = "0.3.41"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use colored::*;
|
|||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use log::{debug, warn};
|
use log::{debug, warn};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use time::UtcDateTime;
|
||||||
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
|
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
|
||||||
|
|
||||||
mod post;
|
mod post;
|
||||||
@@ -80,7 +81,9 @@ impl BlueskyFirehosePrinter {
|
|||||||
return true; // Continue processing
|
return true; // Continue processing
|
||||||
}
|
}
|
||||||
|
|
||||||
let ts = post.get_time_us().unwrap_or(0) / 10_000;
|
let ts = post.get_time_us().unwrap_or(0);
|
||||||
|
let date = UtcDateTime::from_unix_timestamp((ts as i64) / 100_000)
|
||||||
|
.unwrap_or_else(|_| UtcDateTime::UNIX_EPOCH);
|
||||||
|
|
||||||
// Generate HSV color based on timestamp
|
// Generate HSV color based on timestamp
|
||||||
let h = ((ts as f64 / 4.0) % 255.0) / 255.0 * 360.0;
|
let h = ((ts as f64 / 4.0) % 255.0) / 255.0 * 360.0;
|
||||||
@@ -129,7 +132,7 @@ impl BlueskyFirehosePrinter {
|
|||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}{}|type:{}|{}{}{}|hsv:{} type:{} kind:{} commit.type={} operation={}",
|
"{}{}|type:{}|{}{}{}|hsv:{} type:{} kind:{} commit.type={} operation={}",
|
||||||
format!("{}", ts).color(info_color),
|
format!("{date}").color(info_color),
|
||||||
format!("").color(info_color),
|
format!("").color(info_color),
|
||||||
type_str.color(info_color),
|
type_str.color(info_color),
|
||||||
text.color(text_color),
|
text.color(text_color),
|
||||||
@@ -144,7 +147,7 @@ impl BlueskyFirehosePrinter {
|
|||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"{}{}|type:{}|{}{}|hsv:{} type:{} kind:{}",
|
"{}{}|type:{}|{}{}|hsv:{} type:{} kind:{}",
|
||||||
format!("{}", ts).color(info_color),
|
format!("{date}").color(info_color),
|
||||||
format!("").color(info_color),
|
format!("").color(info_color),
|
||||||
type_str.color(info_color),
|
type_str.color(info_color),
|
||||||
text.color(text_color),
|
text.color(text_color),
|
||||||
|
|||||||
Reference in New Issue
Block a user