You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use this project as a js library, but I found the output optimumInterval sometimes can be a NaN value:
When I put three review histories into it:
mark=5,date=now
mark=3,date=now+10days
mark=3,date=now+100days
the final optimumInterval will be a NaN value:
repetition:0,date:2021-01-01,mark:5,optimumInterval:4.0 hour
repetition:1,date:2021-01-11,mark:3,optimumInterval:59.2 days
repetition:2,date:2021-04-11,mark:3,optimumInterval:NaN days
code to reproduce this issue:
const sm_util = require("./sm.js")
const sm = new sm_util.SM()
const ONE_DAY = 24 * 3600 * 1000
function mytest() {
const now = new Date().getTime()
const item = sm.addItem("")
answer_core(5, item, new Date(now))
answer_core(3, item, new Date(now + ONE_DAY * 10))
answer_core(3, item, new Date(now + ONE_DAY * 100))
}
function answer_core(mark, item, date) {
sm.answer(mark, item, date)
const data = item.data()
const optimumInterval = format_interval(data["optimumInterval"])
const repetition = data["repetition"]
console.log(`repetition:${repetition},date:${formatDate(date)},mark:${mark},optimumInterval:${optimumInterval}`)
}
function format_interval(optimumInterval) {
let days = optimumInterval / 24 / 3600 / 1000
if (days < 1.0) {
days = (optimumInterval / 1000 / 3600).toFixed(1) + " hour"
} else {
days = days.toFixed(1) + " days"
}
return days
}
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
mytest()
The text was updated successfully, but these errors were encountered:
I want to use this project as a js library, but I found the output optimumInterval sometimes can be a NaN value:
When I put three review histories into it:
mark=5,date=now
mark=3,date=now+10days
mark=3,date=now+100days
the final optimumInterval will be a NaN value:
code to reproduce this issue:
The text was updated successfully, but these errors were encountered: