Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- calculateTime() {
- const d = new Date();
- const currentDay = d.getDay();
- const currentHour = d.getHours();
- const currentMinute = d.getMinutes();
- const currentSecond = d.getSeconds();
- const spawnDay = this.dayStringToInt(this.boss.DAYOFWEEK);
- const spawnHour = parseInt(this.boss.SPAWNSAT.HOUR);
- const spawnMinute = parseInt(this.boss.SPAWNSAT.MINUTE);
- let dayDifference = 0;
- if (currentDay !== spawnDay && spawnDay === 0) {
- dayDifference = 6 - currentDay;
- }
- else if (currentDay !== spawnDay && spawnDay !== 0 && currentDay > spawnDay) {
- dayDifference = 6 - currentDay - spawnDay;
- }
- else if (currentDay !== spawnDay && spawnDay !== 0 && currentDay < spawnDay) {
- dayDifference = spawnDay - currentDay - 1;
- }
- else {
- console.log('woops, send this to the admin: '+this.boss)
- }
- let hourDifference = 0;
- if (currentDay === spawnDay) {
- hourDifference = spawnHour - currentHour;
- }
- else {
- hourDifference = (24 * dayDifference + (24 - currentHour)) + spawnHour;
- }
- let minuteDifference = spawnMinute - currentMinute;
- if (minuteDifference < 0) {
- minuteDifference = 59 + minuteDifference;
- hourDifference--;
- }
- minuteDifference--;
- let secondDifference = 60 - currentSecond;
- this.secTillBoss = (hourDifference * 60 * 60 * 1000) + (minuteDifference * 60 * 1000) + (secondDifference * 1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement