2017-06-23 23:32:24 +02:00
|
|
|
import moment from 'moment';
|
|
|
|
|
2017-06-14 00:39:45 +02:00
|
|
|
let time = {
|
|
|
|
|
|
|
|
unix() {
|
2017-06-19 21:18:22 +02:00
|
|
|
return Math.floor((new Date()).getTime() / 1000);
|
2017-06-19 00:06:10 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
unixMs() {
|
|
|
|
return (new Date()).getTime();
|
|
|
|
},
|
|
|
|
|
|
|
|
unixMsToS(ms) {
|
2017-06-19 21:18:22 +02:00
|
|
|
return Math.floor(ms / 1000);
|
2017-06-23 23:32:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
unixMsToIso(ms) {
|
|
|
|
return moment.unix(ms / 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z';
|
|
|
|
},
|
2017-06-14 00:39:45 +02:00
|
|
|
|
2017-06-27 01:20:01 +02:00
|
|
|
msleep(ms) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve();
|
|
|
|
}, ms);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
sleep(seconds) {
|
|
|
|
return this.msleep(seconds * 1000);
|
|
|
|
},
|
|
|
|
|
2017-06-14 00:39:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export { time };
|