// Модуль для работы с датами let GMT_offset = 0; module.exports = { setGMT: function(offset) { GMT_offset = offset; console.log('Установлен часовой пояс GMT+' + offset); }, getGMT: function() { return GMT_offset; }, now: function() { const now = new Date(); return new Date(now.getTime() + GMT_offset * 60 * 60 * 1000); }, format: function(date, format = 'YYYY-MM-DD HH:mm:ss') { const d = date || this.now(); const year = d.getFullYear(); const month = String(d.getMonth() + 1).padStart(2, '0'); const day = String(d.getDate()).padStart(2, '0'); const hours = String(d.getHours()).padStart(2, '0'); const minutes = String(d.getMinutes()).padStart(2, '0'); const seconds = String(d.getSeconds()).padStart(2, '0'); return format .replace('YYYY', year) .replace('MM', month) .replace('DD', day) .replace('HH', hours) .replace('mm', minutes) .replace('ss', seconds); } };