mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
lastCron: setting as difference between two dates on midnight,
currently a bug where it calculates the difference in 24h between two dates
This commit is contained in:
@@ -512,17 +512,24 @@ ready(function(model) {
|
||||
poormanscron = function() {
|
||||
var DAY, daysPassed, lastCron, today;
|
||||
lastCron = model.get('_user.lastCron');
|
||||
lastCron = lastCron ? new Date(lastCron) : new Date();
|
||||
if (lastCron) {
|
||||
lastCron = new Date(model.get('_user.lastCron'));
|
||||
} else {
|
||||
lastCron = new Date();
|
||||
model.set('_user.lastCron', lastCron);
|
||||
}
|
||||
lastCron = new Date("" + (lastCron.getMonth()) + "/" + (lastCron.getDate()) + "/" + (lastCron.getFullYear()));
|
||||
console.log(lastCron);
|
||||
DAY = 1000 * 60 * 60 * 24;
|
||||
today = new Date();
|
||||
today = new Date("" + (today.getMonth()) + "/" + (today.getDate()) + "/" + (today.getFullYear()));
|
||||
daysPassed = Math.floor((today.getTime() - lastCron.getTime()) / DAY);
|
||||
if (daysPassed > 0) {
|
||||
_(daysPassed).times(function() {
|
||||
return endOfDayTally();
|
||||
});
|
||||
lastCron = new Date();
|
||||
return model.set('_user.lastCron', today);
|
||||
}
|
||||
return model.set('_user.lastCron', lastCron);
|
||||
};
|
||||
poormanscron();
|
||||
setInterval((function() {
|
||||
|
||||
Reference in New Issue
Block a user