/usr/lib/nodejs/date-time/index.js is in node-date-time 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 'use strict';
const timeZone = require('time-zone');
module.exports = options => {
options = Object.assign({
date: new Date(),
local: true,
showTimeZone: false,
showMilliseconds: false
}, options);
let date = options.date;
if (options.local) {
// Offset the date so it will return the correct value when getting the ISO string
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);
};
|