Paste
Pasted as JavaScript by AACargo ( 6 years ago )
const moment = require('moment');
module.exports = class Cargo {
constructor(startTime) {
this.startTime = startTime;
}
addWayTwoCrownToSolis(date) {
return moment(date, 'DD.MM.YYYY HH:mm:ss')
.add({ minutes: 10, seconds: 34 })
.format('DD.MM.YYYY HH:mm:ss');
}
addWaySolisToTwoCrown(date) {
return moment(date, 'DD.MM.YYYY HH:mm:ss')
.add({ minutes: 10, seconds: 35 })
.format('DD.MM.YYYY HH:mm:ss');
}
addStandTwoCrown(date) {
return moment(date, 'DD.MM.YYYY HH:mm:ss')
.add({ minutes: 20, seconds: 0 })
.format('DD.MM.YYYY HH:mm:ss');
}
addStandSolis(date) {
return moment(date, 'DD.MM.YYYY HH:mm:ss')
.add({ minutes: 20, seconds: 0 })
.format('DD.MM.YYYY HH:mm:ss');
}
async createRound(startTime) {
const array = [];
await Promise.resolve()
.then(() => {
const time = this.addWayTwoCrownToSolis(startTime);
array.push({ time, status: 'standInSolis' });
return time;
})
.then(date => {
const time = this.addStandSolis(date);
array.push({ time, status: 'wayToTwoCrown' });
return time;
})
.then(date => {
const time = this.addWaySolisToTwoCrown(date);
array.push({ time, status: 'standInTwoCrown' });
return time;
})
.then(date => {
const time = this.addStandTwoCrown(date);
array.push({ time, status: 'wayToSolis' });
})
.catch(err => console.log(err));
return await array;
}
async timesGenerate() {
let times = await [{ time: this.startTime, status: 'wayToSolis' }];
for (let i = 0; i < 1000; i++) {
const data = await this.createRound(times[times.length - 1].time);
await times.push(...data);
}
return await times;
}
};
Revise this Paste