function buildNewItem(hash, addr, res) { const utcnow = moment.utc().toDate() const item = { _id: nextTorrentId++,
const utcnow = moment.utc().toDate() const today = moment().format('YYYY-MM-DD') if(n_reqs >= 1000) {
const removeOldLogs = () => { RequestLog.remove({ updated_at: {$lte: moment().subtract(1, 'week').toDate()}, }).then((res) => { console.log('res', res); }).catch((err)=> { console.log('err:', err); }); }
function getEndDate (startDate, duration, durationUnit, t) { const startDateMoment = moment(startDate) if (!startDateMoment.isValid()) { throw new Error(t('api/appendPeriod/startDateNotValid')) } const endDateMoment = startDateMoment.add(duration, durationUnit) if (!endDateMoment.isValid()) { throw new Error(t('api/appendPeriod/durationOrDurationUnitNotValid', { duration, durationUnit })) } return endDateMoment.toDate() }
it('should be able to parse date.js valid string', function (done) { var tenMinutesFromNow = moment().add(10, 'minutes').toDate(); Queue ._parse('10 minutes from now', function (error, date) { expect(date.getMinutes()).to.eql(tenMinutesFromNow.getMinutes()); done(error, date); }); });
async _deleteOldMails() { try { await this.imapService.deleteOldMails( moment() .subtract(this.config.email.deleteMailsOlderThanDays, 'days') .toDate() ) } catch (error) { console.log('can not delete old messages', error) } }
router.get("/", (req, res) => { res.send( IMAGES.map(image => ({ ...image, createdAt: +image.createdAt.toDate() })) ); });
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 }; }
inputTime (prayer) { let d = moment(this.times[prayer], "h:mm a").toDate(), h = d.getHours(), m = d.getMinutes(); if (h < 10) h = '0' + h; if (m < 10) m = '0' + m; return h + ':' + m; }
router.get('/nodeversions', function (req, res) { StatisticsVersions.find({ 'date': {$gt: moment().subtract(3, 'days').toDate()} }) .select('-_id date nodeversions') .exec(function (err, stats) { if (err) { console.log("API - Node Versions", err); return; } res.json(stats); }); });
static fromString(string) { const data = JSON.parse(string); return new VisitorsValueModel({ date: moment(data.date).toDate(), visitors: data.visitors }); }
static fromString(string) { const data = JSON.parse(string); return new MemoryValueModel({ date: moment(data.date).toDate(), memory: data.memory }); }
static fromString(string) { const data = JSON.parse(string); return new AvgTimeValueModel({ date: moment(data.date).toDate(), avgTime: data.avgTime }); }
router.get('/blockcountsovertime', function (req, res) { StatisticsBlockcounts.find({ 'date': {$gt: moment().subtract(1, 'days').toDate()} }) .select('-_id date blockcounts') .exec(function (err, stats) { if (err) { console.log("API - Blockcounts over time", err); return; } res.json(stats); }); });