add since field
This commit is contained in:
parent
b1d8500611
commit
cfbf5dc609
1 changed files with 11 additions and 2 deletions
|
@ -8,13 +8,22 @@ use serde::Serialize;
|
||||||
/// Response for /love
|
/// Response for /love
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct InfoLove {
|
struct InfoLove {
|
||||||
unix_epoch: u32,
|
unix_epoch: u64,
|
||||||
|
since: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/love")]
|
#[get("/love")]
|
||||||
pub async fn love() -> impl Responder {
|
pub async fn love() -> impl Responder {
|
||||||
|
let target = 1_605_576_600;
|
||||||
|
let current_time: u64 = Utc::now().timestamp().try_into().unwrap();
|
||||||
|
|
||||||
HttpResponse::Ok().json(InfoLove {
|
HttpResponse::Ok().json(InfoLove {
|
||||||
unix_epoch: 1_605_576_600,
|
unix_epoch: target,
|
||||||
|
since: {
|
||||||
|
let duration_epoch = current_time - target;
|
||||||
|
let duration = Duration::from_secs(duration_epoch);
|
||||||
|
format_duration(duration).to_string()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue