Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@user1823
Copy link
Contributor

@user1823 user1823 commented Apr 6, 2025

Previously, 363 days would be converted to 12.1 months, which is quite confusing because

  • a user would think that if the value is more than 12 months, why it isn't displayed in years
  • the value is actually less than a year, which is counterintuitive as 12.1 m suggests a value more than a year.

Previously, 363 days would be converted to 12.1 months, which is quite confusing because
- a user would think that if the value is more than 12 months, why it isn't displayed in years
- the value is actually less than a year, which is counterintuitive as 12.1 m suggests a value more than a year.
} else if (secs < MONTH) {
return TimespanUnit.Days;
} else if (secs < YEAR) {
} else if (secs < 12.0 * MONTH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to keep the old behaviour (i.e a year being 360 days) here?

Copy link
Contributor Author

@user1823 user1823 Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make it 365 days here, a time like 363 days would be displayed as 12.1 months, which is confusing.

I am adding another test in the corresponding Rust code that would fail if the part corresponding to this is changed in the Rust code.

@dae
Copy link
Member

dae commented Apr 11, 2025

While I appreciate the problem you're trying to solve, I find this approach a bit confusing as we're special-casing one unit. What if we just made the month constant more accurate? It's likely going to require some tests to be updated too though.

diff --git a/rslib/src/scheduler/timespan.rs b/rslib/src/scheduler/timespan.rs
index f98c1ce69..bdbbdaeab 100644
--- a/rslib/src/scheduler/timespan.rs
+++ b/rslib/src/scheduler/timespan.rs
@@ -57,7 +57,7 @@ const SECOND: f32 = 1.0;
 const MINUTE: f32 = 60.0 * SECOND;
 const HOUR: f32 = 60.0 * MINUTE;
 const DAY: f32 = 24.0 * HOUR;
-const MONTH: f32 = 30.0 * DAY;
+const MONTH: f32 = 30.417 * DAY;
 const YEAR: f32 = 365.0 * DAY;
 
 #[derive(Clone, Copy)]
@@ -189,5 +189,9 @@ mod test {
         assert_eq!(time_span(90.0, &tr, false), "1.5 minutes");
         assert_eq!(time_span(45.0 * 86_400.0, &tr, false), "1.5 months");
         assert_eq!(time_span(365.0 * 86_400.0 * 1.5, &tr, false), "1.5 years");
+        assert_eq!(time_span(364.0 * 86_400.0, &tr, false), "12 months");
+        assert_eq!(time_span(364.0 * 86_400.0, &tr, true), "11.97 months");
+        assert_eq!(time_span(365.0 * 86_400.0, &tr, false), "1 year");
+        assert_eq!(time_span(365.0 * 86_400.0, &tr, true), "1 year");
     }
 }

@user1823
Copy link
Contributor Author

I updated the PR to use the average duration of month (as you suggested) and updated the relevant tests.

@dae
Copy link
Member

dae commented Apr 13, 2025

Thank you!

@dae dae merged commit e546c6d into ankitects:main Apr 13, 2025
1 check passed
@user1823 user1823 deleted the patch-1 branch April 13, 2025 04:30
@david-allison
Copy link
Contributor

david-allison commented Jun 14, 2025

@user1823 The Reviews - Time section of the statistics** can be measured in months.

Will this change mean that power users will 'lose' progress if their 'total studied' time is > 1 month?

const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount;

Just in general, using "month" in this sense feels strange to me as a native English speaker. I'd prefer "hours" or maybe "days".

@user1823
Copy link
Contributor Author

user1823 commented Jun 15, 2025

@david-allison, I suppose that you mean the reviews section of the statistics, not settings.

Yes, you are right. Unfortunately, this change has the side effect of slightly decreasing the reported total study time if that's more than a month.

Also, as you said, I too feel that using "months" to describe study time is weird. This has been discussed on the forums too and Damien would accept a PR that prevents the study time from being shown in a unit greater than "hours".

https://forums.ankiweb.net/t/reviews-graph-units-of-total-time-studied-suggestion/61237/14

Edit: I opened a PR

dae pushed a commit that referenced this pull request Jun 18, 2025
* Add maxUnit argument to naturalUnit

* Limit study time to hours in reviews graph

Relevant discussions:
- https://forums.ankiweb.net/t/reviews-graph-units-of-total-time-studied-suggestion/61237
- https://forums.ankiweb.net/t/why-does-anki-display-study-time-in-months/37722
- https://forums.ankiweb.net/t/poll-use-hours-in-total-time-stats/62076
- #3901 (comment)

* Use the new approach for native stability in Card Info

* Use a simpler approach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants