1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00
joplin/ReactNativeClient/lib/time-utils.js
2017-07-07 18:19:24 +01:00

39 lines
617 B
JavaScript

import moment from 'moment';
let time = {
unix() {
return Math.floor((new Date()).getTime() / 1000);
},
unixMs() {
return (new Date()).getTime();
},
unixMsToS(ms) {
return Math.floor(ms / 1000);
},
unixMsToIso(ms) {
return moment.unix(ms / 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z';
},
unixMsToIsoSec(ms) {
return moment.unix(ms / 1000).utc().format('YYYY-MM-DDTHH:mm:ss') + 'Z';
},
msleep(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms);
});
},
sleep(seconds) {
return this.msleep(seconds * 1000);
},
}
export { time };