Skip to content

Commit

Permalink
fix: using unix timestamps for dates in api response
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jul 19, 2024
1 parent b5a3e4a commit 19ce307
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/api/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
collections::HashMap,
process::Stdio,
sync::{atomic::AtomicU64, Arc, Mutex},
time::SystemTime,
time::{SystemTime, UNIX_EPOCH},
};

use actix_web::Result;
Expand Down Expand Up @@ -34,23 +34,29 @@ fn get_current_exe() -> Result<String, Error> {

#[derive(Serialize)]
pub(crate) struct Completion {
completed_at: SystemTime,
completed_at: u64,
exit_code: i32,
error: Option<Error>,
}

impl Completion {
fn with_status(exit_code: i32) -> Self {
Self {
completed_at: SystemTime::now(),
completed_at: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
exit_code,
error: None,
}
}

fn with_error(error: Error) -> Self {
Self {
completed_at: SystemTime::now(),
completed_at: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
exit_code: -1,
error: Some(error),
}
Expand Down Expand Up @@ -138,7 +144,7 @@ pub(crate) struct Wrapper {
process_id: u32,
client: String,
argv: Vec<String>,
started_at: SystemTime,
started_at: u64,

statistics: Arc<Mutex<Statistics>>,
loot: Arc<Mutex<Vec<Loot>>>,
Expand Down Expand Up @@ -220,7 +226,10 @@ impl Wrapper {
});

Ok(Self {
started_at: SystemTime::now(),
started_at: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
session_id,
process_id,
client,
Expand Down

0 comments on commit 19ce307

Please sign in to comment.