mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Feat/minutes only today stats
This commit is contained in:
parent
d13c117e80
commit
44d804d0b3
2 changed files with 9 additions and 1 deletions
|
@ -139,6 +139,13 @@ impl Timespan {
|
||||||
self.unit
|
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
|
/// Return a new timespan in the most appropriate unit, eg
|
||||||
/// 70 secs -> timespan in minutes
|
/// 70 secs -> timespan in minutes
|
||||||
pub fn natural_span(self) -> Timespan {
|
pub fn natural_span(self) -> Timespan {
|
||||||
|
|
|
@ -5,9 +5,10 @@ use anki_i18n::I18n;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::scheduler::timespan::Timespan;
|
use crate::scheduler::timespan::Timespan;
|
||||||
|
use crate::scheduler::timespan::TimespanUnit;
|
||||||
|
|
||||||
pub fn studied_today(cards: u32, secs: f32, tr: &I18n) -> String {
|
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 amount = span.as_unit();
|
||||||
let unit = span.unit().as_str();
|
let unit = span.unit().as_str();
|
||||||
let secs_per_card = if cards > 0 {
|
let secs_per_card = if cards > 0 {
|
||||||
|
|
Loading…
Reference in a new issue