generated from PlexSheep/rs-base
show mode of timebar with extra info #18
|
@ -24,6 +24,12 @@ impl TimeBarLength {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<TimeBarLength> for chrono::Duration {
|
||||||
|
fn from(value: TimeBarLength) -> Self {
|
||||||
|
Self::new(value.as_secs(), 0).expect("seconds out of bounds, cannot create duration")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for TimeBarLength {
|
impl Default for TimeBarLength {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Minute
|
Self::Minute
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use chrono::{DateTime, Local, SubsecRound};
|
use chrono::{DateTime, Local, SubsecRound, Timelike};
|
||||||
use libpt::log::{debug, error, trace};
|
use libpt::log::{debug, error, trace};
|
||||||
use ratatui::layout::{Alignment, Rect};
|
use ratatui::layout::{Alignment, Rect};
|
||||||
use ratatui::style::{Style, Stylize};
|
use ratatui::style::{Style, Stylize};
|
||||||
|
@ -150,7 +150,12 @@ pub fn timebarw_label<'a>(
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
Paragraph::new(format!("{time_now} / {len}"))
|
let until = last_reset
|
||||||
|
.checked_add_signed(len.into())
|
||||||
|
.expect("could not calculate when the countdown finishes");
|
||||||
|
let timestamp_until: String =
|
||||||
|
format!("{}:{}:{}", until.hour(), until.minute(), until.second());
|
||||||
|
Paragraph::new(format!("{time_now} / {len} ({timestamp_until})"))
|
||||||
.alignment(Alignment::Center)
|
.alignment(Alignment::Center)
|
||||||
.block(
|
.block(
|
||||||
Block::default().padding(Padding::right(if inner_rect.width > 80 {
|
Block::default().padding(Padding::right(if inner_rect.width > 80 {
|
||||||
|
|
Reference in New Issue