Feat/minutes only today stats

This commit is contained in:
Luc Mcgrady 2025-08-04 18:02:48 +01:00
parent d13c117e80
commit 44d804d0b3
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
2 changed files with 9 additions and 1 deletions

View file

@ -139,6 +139,13 @@ impl Timespan {
self.unit
}
pub fn to_unit(self, unit: TimespanUnit) -> Timespan {
Timespan {
seconds: self.seconds,
unit,
}
}
/// Return a new timespan in the most appropriate unit, eg
/// 70 secs -> timespan in minutes
pub fn natural_span(self) -> Timespan {

View file

@ -5,9 +5,10 @@ use anki_i18n::I18n;
use crate::prelude::*;
use crate::scheduler::timespan::Timespan;
use crate::scheduler::timespan::TimespanUnit;
pub fn studied_today(cards: u32, secs: f32, tr: &I18n) -> String {
let span = Timespan::from_secs(secs).natural_span();
let span = Timespan::from_secs(secs).to_unit(TimespanUnit::Minutes);
let amount = span.as_unit();
let unit = span.unit().as_str();
let secs_per_card = if cards > 0 {