1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/ReactNativeClient/lib/time-utils.js

47 lines
783 B
JavaScript
Raw Normal View History

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-07-07 19:19:24 +02:00
unixMsToIsoSec(ms) {
return moment.unix(ms / 1000).utc().format('YYYY-MM-DDTHH:mm:ss') + 'Z';
},
2017-07-12 22:39:47 +02:00
unixMsToLocalDateTime(ms) {
return moment.unix(ms / 1000).format('DD/MM/YYYY HH:mm');
},
formatMsToLocal(ms, format) {
2017-07-15 01:12:32 +02:00
return moment(ms).format(format);
},
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 };