function scheduleTime() {
    let time = new Date();
    // Get random time between 0 and 10 minutes
    let rand = Math.floor(Math.random() * 10 * 60 * 1000);
    // Weekends
    if (time.getDay() === 0 || time.getDay() === 7) {
        return 115 * 60 * 1000 + rand;
    } 
    // Non-working hours
    else if (time.getHours() < 7 || time.getHours() > 17) {
        return 55 * 60 * 1000 + rand;
    }
    // Working (school) hours
    else {
        return 25 * 60 * 1000 + rand;
    }
}
/**
 * Gets the the right amount of time to
 * wait before scheduling a new sync operation.
 * Remember a sync operation takes about
 * count(users) * 5 seconds to complete.
 * Meaning 500 users gives ~83 minutes of sync time.
 * After this, the randomised offset is applied 
 * before next sync.
 * 
 * Weekdays:
 *  0000-0700: ~every 60 min
 *  0700-1700: ~every 30 min
 *  1700-2400: ~every 60 min
 * Weekend:
 *  0000-2400: ~every 120 min
 * Then we add a bit of randomness to not
 * load the servers at regular intervals.
 * 
 * @returns (in ms) the amount of time to wait
 */
Gets the the right amount of time to
wait before scheduling a new sync operation.
Remember a sync operation takes about
count(users) * 5 seconds to complete.
Meaning 500 users gives ~83 minutes of sync time.
After this, the randomised offset is applied
before next sync.



@returns (in ms) the amount of time to wait
Gets the the right amount of time to wait before scheduling a new sync operation . Remember a sync operation takes about count ( users ) * 5 seconds to complete . Meaning 500 users gives ~83 minutes of sync time . After this the randomised offset is applied before next sync . @returns ( in ms ) the amount of time to wait
function scheduleTime() {
    let time = new Date();
    let rand = Math.floor(Math.random() * 10 * 60 * 1000);
    if (time.getDay() === 0 || time.getDay() === 7) {
        return 115 * 60 * 1000 + rand;
    } 
    else if (time.getHours() < 7 || time.getHours() > 17) {
        return 55 * 60 * 1000 + rand;
    }
    else {
        return 25 * 60 * 1000 + rand;
    }
}
function scheduleTime ( ) { let time = new Date ( ) ; let rand = Math . floor ( Math . random ( ) * 10 * 60 * 1000 ) ; if ( time . getDay ( ) === 0 || time . getDay ( ) === 7 ) { return 115 * 60 * 1000 + rand ; } else if ( time . getHours ( ) < 7 || time . getHours ( ) > 17 ) { return 55 * 60 * 1000 + rand ; } else { return 25 * 60 * 1000 + rand ; } }
Gets the the right amount of time to
 wait before scheduling a new sync operation.
Gets the the right amount of time to wait before scheduling a new sync operation .
// Get random time between 0 and 10 minutes // Weekends // Non-working hours // Working (school) hours