add debug time command

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-24 00:15:03 +00:00
parent 85f734ec74
commit 111cbea6fc
2 changed files with 10 additions and 2 deletions

View file

@ -2,14 +2,14 @@ use std::{
collections::{BTreeMap, HashMap},
fmt::Write,
sync::{Arc, Mutex},
time::Instant,
time::{Instant, SystemTime},
};
use api::client::validate_and_add_event_id;
use conduit::{
debug, info, log,
log::{capture, Capture},
warn, Error, PduEvent, Result,
utils, warn, Error, PduEvent, Result,
};
use ruma::{
api::{client::error::ErrorKind, federation::event::get_room_state},
@ -739,3 +739,8 @@ pub(super) async fn runtime_interval(_body: Vec<&str>) -> Result<RoomMessageEven
"Runtime metrics require building with `tokio_unstable`.",
))
}
pub(super) async fn time(_body: Vec<&str>) -> Result<RoomMessageEventContent> {
let now = SystemTime::now();
Ok(RoomMessageEventContent::text_markdown(utils::time::format(now, "%+")))
}

View file

@ -175,6 +175,9 @@ pub(super) enum DebugCommand {
/// invocation.
RuntimeInterval,
/// - Print the current time
Time,
/// - Developer test stubs
#[command(subcommand)]
#[allow(non_snake_case)]