'use strict';
const timeZone = require('time-zone');
const dateTime = options => {
options = Object.assign({
date: new Date(),
local: true,
showTimeZone: false,
showMilliseconds: false
}, options);
let {date} = options;
if (options.local) {
date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
}
let end = '';
if (options.showTimeZone) {
end = ' UTC' + (options.local ? timeZone(date) : '');
}
if (options.showMilliseconds && date.getUTCMilliseconds() > 0) {
end = ` ${date.getUTCMilliseconds()}ms${end}`;
}
return date
.toISOString()
.replace(/T/, ' ')
.replace(/\..+/, end);
};
module.exports = dateTime;
module.exports.default = dateTime;