mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Update today.rs
This commit is contained in:
parent
109b6c5647
commit
7e110542d6
1 changed files with 4 additions and 6 deletions
|
@ -8,18 +8,16 @@ use crate::scheduler::timespan::Timespan;
|
||||||
use crate::scheduler::timespan::TimespanUnit;
|
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 mut span = Timespan::from_secs(secs).natural_span();
|
||||||
let unit = std::cmp::min(span.unit(), TimespanUnit::Minutes);
|
let unit = std::cmp::min(span.unit(), TimespanUnit::Minutes);
|
||||||
let amount = match unit {
|
let span = Timespan { seconds: span.seconds, unit: unit };
|
||||||
TimespanUnit::Seconds => secs,
|
let amount = span.as_unit();
|
||||||
TimespanUnit::Minutes => secs / 60.0,
|
|
||||||
};
|
|
||||||
let secs_per_card = if cards > 0 {
|
let secs_per_card = if cards > 0 {
|
||||||
secs / (cards as f32)
|
secs / (cards as f32)
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
tr.statistics_studied_today(unit, secs_per_card, amount, cards)
|
tr.statistics_studied_today(unit.as_str(), secs_per_card, amount, cards)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue