add since string
This commit is contained in:
parent
cd1dafdc26
commit
5674f6b592
1 changed files with 23 additions and 12 deletions
|
@ -23,25 +23,36 @@ pub async fn love() -> impl Responder {
|
||||||
struct InfoBTF {
|
struct InfoBTF {
|
||||||
unix_epoch: u64,
|
unix_epoch: u64,
|
||||||
countdown: String,
|
countdown: String,
|
||||||
|
since: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/backtofrance")]
|
#[get("/backtofrance")]
|
||||||
pub async fn btf() -> impl Responder {
|
pub async fn btf() -> impl Responder {
|
||||||
let target = 1_736_618_100;
|
let target = 1_736_618_100;
|
||||||
|
let start = 1_724_832_000;
|
||||||
let current_time: u64 = Utc::now().timestamp().try_into().unwrap();
|
let current_time: u64 = Utc::now().timestamp().try_into().unwrap();
|
||||||
|
|
||||||
let info = InfoBTF {
|
if current_time > target {
|
||||||
unix_epoch: target,
|
HttpResponse::Ok().json(InfoBTF {
|
||||||
countdown: if current_time > target {
|
unix_epoch: target,
|
||||||
"Already happened".to_owned()
|
countdown: "Already happened".to_owned(),
|
||||||
} else {
|
since: "Not relevant anymore".to_owned(),
|
||||||
let duration_epoch = target - current_time;
|
})
|
||||||
let duration = Duration::from_secs(duration_epoch);
|
} else {
|
||||||
format_duration(duration).to_string()
|
HttpResponse::Ok().json(InfoBTF {
|
||||||
},
|
unix_epoch: target,
|
||||||
};
|
countdown: {
|
||||||
|
let duration_epoch = target - current_time;
|
||||||
HttpResponse::Ok().json(info)
|
let duration = Duration::from_secs(duration_epoch);
|
||||||
|
format_duration(duration).to_string()
|
||||||
|
},
|
||||||
|
since: {
|
||||||
|
let duration_epoch = current_time - start;
|
||||||
|
let duration = Duration::from_secs(duration_epoch);
|
||||||
|
format_duration(duration).to_string()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/websites")]
|
#[get("/websites")]
|
||||||
|
|
Loading…
Reference in a new issue