-
-
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
Conversation
e1b3f60
to
4316a42
Compare
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, | ||
) |
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.
Please let me know if the logic in these comments is confusing or wrong!
4316a42
to
b7619e9
Compare
@sobjornstad is using our package in their product (@remnoteio), so I'd like to ask for his advice. |
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.
LGTM
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.
LGTM
// 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, |
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 a utc_offset = 0
and next_day_starts_at = 4
, then the minute_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-L82
So, if I review at 2024-04-28 05:00
, the converted time would be 2024-04-28 01:00
. And if I review at 2024-04-28 03:00
, the converted time would be 2024-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.
If my timezone is UTC with a
utc_offset = 0
andnext_day_starts_at = 4
, then theminute_offset = 240 minutes
.
To be exceedingly pedantic, minute_offset = -240 minutes
; i.e. it's negative. This can be seen in the original code where next_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.
Do you have a plan for the next release? |
Yup gimme a sec! |
I'm not sure if sobjornstad/Remnote uses the Anki revlog format. This PR is only relevant to those using that style; using raw (Editorial time: Honestly, using raw |
Yeah. Timezone shift is hard to deal with if we use the revlog format. I don't know how Anki deal with that. @dae, sorry for bothering you. Has Anki solved this issue? If so, how? |
Anki revlogs do not record timezone info, so Anki is not aware of historical timezone changes. |
Fine. Thanks for that information. |
Sorry for the delay, I didn't check my Discord messages for a while :) What is the “Anki revlog format” in the context of FSRS? Some choice in the API used? We use |
Ah, "Anki revlog format" in the context of I think |
We use |
@sobjornstad, this PR is related to the optimization, so you need to check that part of RemNote rather than scheduler. |
Ah gotcha, I have actually not been involved in the optimizer at all yet. I'll review that and check with Martin tomorrow |
Closes #22
Answering some questions from here:
Agreed.
Please let me know if this PR's example/documentation is insufficient.
I kinda show this in
train.ts
. But to be explicit: