-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
add minute_offset
and update to fsrs 0.6.2
#25
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Submodule fsrs-rs
updated
8 files
+1 −1 | .github/workflows/auto-merge.yml | |
+274 −6 | Cargo.lock | |
+1 −1 | Cargo.toml | |
+14 −22 | src/convertor_tests.rs | |
+5 −5 | src/inference.rs | |
+26 −7 | src/model.rs | |
+4 −4 | src/optimal_retention.rs | |
+8 −12 | src/pre_training.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,25 @@ function computeParameters( | |
// Do not read from memory after `Stop` is posted! | ||
pointer: progress.pointer(), | ||
} satisfies ProgressMessage) | ||
let parameters = fsrs.computeParametersAnki(cids, eases, ids, types, progress) | ||
// MDN states: | ||
// The number of minutes returned by getTimezoneOffset() is positive if the | ||
// local time zone is behind UTC, and negative if the local time zone is ahead of UTC. | ||
// This is useful when going from our timezone to UTC; our local time + offset = UTC. | ||
// However, we want to go from UTC to our timezone. (Anki revlog id is UTC, and we want to convert it to local time.) | ||
// So we flip the sign of `getTimezoneOffset()`. | ||
let timeZoneMinutesOffset = new Date().getTimezoneOffset() * -1 | ||
let ankiNextDayStartsAtMinutes = 4 * 60 | ||
let parameters = fsrs.computeParametersAnki( | ||
// We subtract ankiNextDayStartsAtMinutes because | ||
// we want a review done at, say, 1am to be done for the *prior* day. | ||
// Adding would move it into the future. | ||
timeZoneMinutesOffset - ankiNextDayStartsAtMinutes, | ||
cids, | ||
eases, | ||
ids, | ||
types, | ||
progress, | ||
) | ||
Comment on lines
-138
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please let me know if the logic in these comments is confusing or wrong! |
||
self.postMessage({ | ||
tag: 'Stop', | ||
parameters, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks fine. If my timezone is
UTC
with autc_offset = 0
andnext_day_starts_at = 4
, then theminute_offset = 240 minutes
. find the relevant code and context at this link https://github.com/open-spaced-repetition/fsrs-rs/blame/14a62849af95a0df0f97cc1251390d03a1dda19c/src/convertor_tests.rs#L78-L82So, if I review at
2024-04-28 05:00
, the converted time would be2024-04-28 01:00
. And if I review at2024-04-28 03:00
, the converted time would be2024-04-27 23:00
. Is that correct?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.
Yeah, it's intended. Ideally, we hope the user doesn't do their reviews around the
NextDayStarts
, when they should be sleeping.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.
To be exceedingly pedantic,
minute_offset = -240 minutes
; i.e. it's negative. This can be seen in the original code wherenext_day_starts_at
is subtracted. In this PR's code it's changed to addition, so the subtraction must be done client-side (in Javascript) as explained in the comments.The rest is correct.