-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Limit time studied today to minutes #4242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
|
maybe remove ? |
Luc-Mcgrady
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my pr's way of doing this bit it is cleaner.
This way I can close the duplicate pr.
|
I don't seem to have permission to push into this branch. Please make the following change, based on Luc's suggestions: commit 5cef2bc5b980ded1682bbc9b425a573f0885b505 (HEAD -> patch-1)
Author: Damien Elmes <[email protected]>
Date: Wed Aug 6 18:54:05 2025 +1000
as_provided_unit -> to_unit
Avoids repeating ourselves
https://github.com/ankitects/anki/pull/4242/files#r2252607480
diff --git a/rslib/src/scheduler/timespan.rs b/rslib/src/scheduler/timespan.rs
index 0bc1e0a9a..d3fb3395f 100644
--- a/rslib/src/scheduler/timespan.rs
+++ b/rslib/src/scheduler/timespan.rs
@@ -112,14 +112,10 @@ impl Timespan {
}
/// Returns the value in the given unit
- pub fn as_provided_unit(&self, unit: TimespanUnit) -> f32 {
- match unit {
- TimespanUnit::Seconds => self.seconds,
- TimespanUnit::Minutes => self.seconds / MINUTE,
- TimespanUnit::Hours => self.seconds / HOUR,
- TimespanUnit::Days => self.seconds / DAY,
- TimespanUnit::Months => self.seconds / MONTH,
- TimespanUnit::Years => self.seconds / YEAR,
+ pub fn to_unit(self, unit: TimespanUnit) -> Timespan {
+ Timespan {
+ seconds: self.seconds,
+ unit,
}
}
diff --git a/rslib/src/stats/today.rs b/rslib/src/stats/today.rs
index f9a677be2..d9680c282 100644
--- a/rslib/src/stats/today.rs
+++ b/rslib/src/stats/today.rs
@@ -10,7 +10,7 @@ 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 unit = std::cmp::min(span.unit(), TimespanUnit::Minutes);
- let amount = span.as_provided_unit(unit);
+ let amount = span.to_unit(unit).as_unit();
let secs_per_card = if cards > 0 {
secs / (cards as f32)
} else { |
|
Thank you both! |

https://forums.ankiweb.net/t/suggestion-make-study-time-display-format-consistent/64186/16