const moment = require('moment-timezone'); moment.tz.setDefault(process.env.TZ); const getDayWeeksOut = (day, weeks, time) => { const today = moment().day(); if (day >= today) { weeks--; } let date; date = moment().day(day); if (weeks) { date = date.add(weeks, 'weeks'); } date.set('hours', Math.floor(time)); date.set('minutes', Math.round(time * 60 - Math.floor(time) * 60)); date.set('seconds', 0); return date.valueOf(); }; const originalEvents = [ { groupId: 1, name: 'Thursday Happy Hour', event: 'thursday', votingBegins: 'day-of', votingCloses: '3:00 PM', description: 'Get together every Thursday with friends for happy hour!', date: getDayWeeksOut(4, 2, 17.5), votingType: 'locations' }, { groupId: 2, name: 'Wednesday Virtual Gaming', event: 'wednesday-virtual-gaming', votingBegins: 'day-of', votingCloses: undefined, description: 'Let\'s play some online games!', date: getDayWeeksOut(3, 1, 19), votingType: 'text' } ]; originalEvents.forEach((item, index) => item.id = index + 1); module.exports = originalEvents;