joplin/ReactNativeClient/lib/time-utils.js

43 lines
711 B
JavaScript
Raw Normal View History

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