mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
DRY daysPassed with helpers.daysBetween
This commit is contained in:
@@ -290,12 +290,11 @@ ready(function(model) {
|
||||
return model.set('_items.weapon', content.items.weapon[1]);
|
||||
};
|
||||
exports.poormanscron = poormanscron = function() {
|
||||
var DAY, daysPassed, lastCron, n, today, _k, _results;
|
||||
model.setNull('_user.lastCron', new Date());
|
||||
lastCron = new Date((new Date(model.get('_user.lastCron'))).toDateString());
|
||||
today = new Date((new Date).toDateString());
|
||||
DAY = 1000 * 60 * 60 * 24;
|
||||
daysPassed = Math.floor((today.getTime() - lastCron.getTime()) / DAY);
|
||||
var daysPassed, lastCron, n, today, _k, _results;
|
||||
today = new Date();
|
||||
model.setNull('_user.lastCron', today);
|
||||
lastCron = model.get('_user.lastCron');
|
||||
daysPassed = helpers.daysBetween(lastCron, today);
|
||||
if (daysPassed > 0) {
|
||||
model.set('_user.lastCron', today);
|
||||
_results = [];
|
||||
|
||||
Reference in New Issue
Block a user