function _buildViewData(currentDate, notifications) { notifications.forEach((notification) => { if (!notification.expirationDate) { notification.expired = true; } else { const currentMoment = moment(currentDate).endOf('day'); const expirationMoment = moment(notification.expirationDate).endOf('day'); notification.expired = currentMoment.isAfter(expirationMoment); } }); return notifications; }
router.get('/', function(req, res, next) { Visit.count({ visitTime: { $gt: moment().startOf('day').valueOf(), $lt: moment().endOf('day').valueOf(), }, }) .then(count => res.render('author', { count, })) .catch(next); });
const getMaxEndDate = (now, daysBeforeEndDate) => moment(now) .subtract(6, 'hours') .subtract(30, 'minutes') .add(daysBeforeEndDate, 'days') .endOf('day')
getMonthDateRange(year, month) { // month in moment is 0 based, so 9 is actually october, subtract 1 to compensate // array is 'year', 'month', 'day', etc var startDate = moment([year, month - 1]); // Clone the value before .endOf() var endDate = moment(startDate).endOf('month'); // just for demonstration: console.log(startDate.toDate()); console.log(endDate.toDate()); // make sure to call toDate() for plain JavaScript date type return { start: startDate, end: endDate }; }
const getTasks = (req, res) => { const date = req.query.date ? req.query.date : moment().endOf('day').toDate() app.db('tasks') .where({ userId: req.user.id }) .where('estimateAt', '<=', date) .orderBy('estimateAt') .then(tasks => res.json(tasks)) .catch(err => res.status(400).json(err)) }
Template.pagePanelDashboard.onCreated(function () { this.startOfMonth = moment().startOf("month").toDate(); this.endOfMonth = moment().endOf("month").toDate(); });
constructor(data) { this.chart = data.chart; this.datasets = data.datasets; // make sure the dates start from midnight if (this.chart.startDate) { this.chart.startDate = moment(this.chart.startDate).startOf("day"); } if (this.chart.endDate) { this.chart.endDate = moment(this.chart.endDate).endOf("day"); } // if (this.chart.currentEndDate) { // const timeDiff = this.chart.endDate.diff(this.chart.startDate, "days"); // this.chart.endDate = moment(); // this.chart.startDate = this.chart.endDate.subtract(timeDiff, "days"); // } }
router.post('/generate_holidays', block_access.actionAccessMiddleware("cra_team", "create"), function (req, res) { var countryLang = req.body.lang.split('-'); var country = countryLang[1]; var lang = countryLang[0]; var team_id = req.body.team_id; var yearStart = moment().startOf('year').toDate().getTime(); var yearEnd = moment().endOf('year').toDate().getTime(); holidaysApi({ country: country, lang: lang, start: yearStart, end: yearEnd }, function(err, holidays) { if (err) { console.error(err); return entity_helper.error(err, req, res); } var bulkCreate = []; for (var i = 0; i < holidays.length; i++) { var date = new Date(holidays[i].start); bulkCreate.push({f_date: date, fk_id_cra_team: team_id, f_label: holidays[i].summary}); } models.E_cra_calendar_exception.bulkCreate(bulkCreate).then(function() { res.redirect('/cra_team/show?id='+team_id+'/#r_cra_calendar_exception'); }); }); });
$(function () { function cb(start, end) { $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); } $('#reportrange').daterangepicker({ startDate: start, endDate: end, autoApply: true, timePicker: true, timePicker24Hour: true, timePickerIncrement: 10, timePickerSeconds: true, // minDate: '', ranges: { 'Today': [moment().startOf('day'), moment()], 'Yesterday': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')], 'Last 7 Days': [moment().subtract(6, 'days').startOf('day'), moment().endOf('day')], 'Last 30 Days': [moment().subtract(29, 'days').startOf('day'), moment().endOf('day')], 'This Month': [moment().startOf('month'), moment().endOf('month')], 'This Month': [moment().startOf('month'), moment()], 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } }, cb); cb(start, end); });
async index (req, res) { const appointments = await Appointment.findAll({ include: [{ model: User, as: 'user' }], where: { provider_id: req.session.user.id, date: { [Op.between]: [ moment() .startOf('day') .format(), moment() .endOf('day') .format() ] } } }); // If there is no appointment at the moment, give the user a message if (appointments.length === 0) { req.flash('error', 'There is no schedule for today up to this moment.'); return res.redirect('/app/dashboard'); } return res.render('schedule/index', { appointments }); }
contract.properties.filter((property) => { const entryMoment = moment(property.entryDate, 'DD/MM/YYYY').startOf('day'); const exitMoment = moment(property.exitDate, 'DD/MM/YYYY').endOf('day'); return currentMoment.isBetween(entryMoment, exitMoment, contract.frequency, '[]'); }).forEach(function (property) { if (property.property) { const name = property.property.name || ''; const preTaxAmount = property.property.price || 0; const charges = property.property.expense || 0; rent.preTaxAmounts.push({ description: name, amount: preTaxAmount }); rent.charges.push({ description: `charges ${name}`, amount: charges }); } });
const getCancelledAtMinMax = (now = moment()) => { const maxCancelledAt = moment(now) .subtract(DAYS_AFTER_CANCELLATION, 'days') .endOf('day') const minCancelledAt = moment(now) .subtract(MAX_DAYS_AFTER_CANCELLATION, 'days') .startOf('day') return { maxCancelledAt, minCancelledAt } }
// statsCollection // filter the set of objects to collect those between two dates function itemsByDates(req, res) { nodeLogger('Starting GetItems/date'); var startMoment = moment(req.params.startDate); var endMoment = moment(req.params.endDate); var startDate = startMoment.startOf('day'); var endDate = endMoment.endOf('day'); nodeLogger('Starting GetItems/date startDate='+startDate+ ' endDate='+endDate); var allData; fs.readFile('purchases.json', 'utf8', function (err, data) { if (err) throw err; allData = JSON.parse(data); var itemsList=[]; for(var i=0; i< allData.length; ++i) { var item=allData[i]; var itemDate = moment(item['date']); if((itemDate > startDate ) && (itemDate < endDate)) itemsList.push(item); } res.send(JSON.stringify(itemsList)); }); }
Meteor.publish('statistics', function() { if (!this.userId) return []; const startOfYear = moment().startOf('year').toDate(); const endOfYear = moment().endOf('year').toDate(); const messages = Messages.find({ userId: this.userId, sentAt: { $gte: startOfYear, $lte: endOfYear } }, { fields: { opens: 1, clicks: 1, sentAt: 1, status: 1 } }); const sendGridError = Settings.find({ userId: this.userId }, { fields: { sendStatsError: 1 } }); const stats = Statistics.find({ userId: this.userId, }); return [messages, stats, sendGridError]; });
constructor(data) { this.chart = data.chart; this.datasets = data.datasets; // make sure the dates start from midnight if (this.chart.startDate) { this.chart.startDate = moment(this.chart.startDate).startOf("day"); } if (this.chart.endDate) { this.chart.endDate = moment(this.chart.endDate).endOf("day"); } // if (this.chart.currentEndDate) { // const timeDiff = this.chart.endDate.diff(this.chart.startDate, "days"); // this.chart.endDate = moment(); // this.chart.startDate = this.chart.endDate.subtract(timeDiff, "days"); // } }