// 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); }
function formatDate() { var date = new Date(); var result = []; result.push(date.getFullYear()); result.push(padding(date.getMonth() + 1)); result.push(padding(date.getDate())); result.push(padding(date.getHours())); result.push(padding(date.getMinutes())); result.push(padding(date.getSeconds())); result.push(paddingMS(date.getMilliseconds())); return result.join(''); }
it('should collect a yesterday\'s datapoint if it does not exist', async () => { const getMetricDataStub = sinon.stub(MockService.prototype, 'getMetricData').returns([]) const params = generateConstructorParams() const metric = new Metric(params) metric.calculateUncollectedDates = () => 1 await metric.collect() assert(getMetricDataStub.calledTwice) const argsAtSecondCall = getMetricDataStub.args[1] const actualBegin = argsAtSecondCall[2] const actualEnd = argsAtSecondCall[3] const now = new Date() assert(actualBegin.getTime() === new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1).getTime()) assert(actualEnd.getTime() === new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime()) })
const buildDates = () => { const currDate = new Date() const today = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` currDate.setDate(currDate.getDate() - 1) const yesterday = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` return [yesterday, today] }
const getExpiryDate = () => { const expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + config.DATA_EXPIRY_IN_DAYS); return expiryDate; }
let formatDate = function(str) { let date = new Date(str); let months = 'January February March April May June July August September October November December'.split(' '); let ends = ['th', 'st', 'nd', 'rd', 'th']; let y = chalk.bold(date.getFullYear()); let m = chalk.bold(months[date.getMonth()]); let d = chalk.bold(date.getDate()); let e = chalk.bold(ends[d] || 'th'); let hh = chalk.bold(formatDigits(date.getHours(), 2)); let mm = chalk.bold(formatDigits(date.getMinutes(), 2)); let ss = chalk.bold(formatDigits(date.getSeconds(), 2)); let ms = chalk.bold(formatDigits(date.valueOf() % 1000, 3)); return `${m} ${d}${e}, ${y} at ${hh}:${mm}:${ss}.${ms}`; }
get date() { const _ = new Date(); return [_.getFullYear(), _.getMonth() + 1, _.getDate()].join('-'); }
export function getFormattedDateTime(date = new Date()) { return `${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${padLeadingZero(date.getMinutes())}:${padLeadingZero(date.getSeconds())}`; }
// 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); }
// 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [ pad( d.getHours() ), pad( d.getMinutes() ), pad( d.getSeconds() ) ].join( ':' ); return [ d.getDate(), months[ d.getMonth() ], time ].join( ' ' ); }
function formatDate() { var date = new Date(); var result = []; result.push(date.getFullYear()); result.push(padding(date.getMonth() + 1)); result.push(padding(date.getDate())); result.push(padding(date.getHours())); result.push(padding(date.getMinutes())); result.push(padding(date.getSeconds())); result.push(paddingMS(date.getMilliseconds())); return result.join(''); }
const buildDates = () => { const currDate = new Date() const today = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` currDate.setDate(currDate.getDate() - 1) const yesterday = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` return [yesterday, today] }
// 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); }
let formatDate = function(str) { let date = new Date(str); let months = 'January February March April May June July August September October November December'.split(' '); let ends = ['th', 'st', 'nd', 'rd', 'th']; let y = chalk.bold(date.getFullYear()); let m = chalk.bold(months[date.getMonth()]); let d = chalk.bold(date.getDate()); let e = chalk.bold(ends[d] || 'th'); let hh = chalk.bold(formatDigits(date.getHours(), 2)); let mm = chalk.bold(formatDigits(date.getMinutes(), 2)); let ss = chalk.bold(formatDigits(date.getSeconds(), 2)); let ms = chalk.bold(formatDigits(date.valueOf() % 1000, 3)); return `${m} ${d}${e}, ${y} at ${hh}:${mm}:${ss}.${ms}`; }
it('should collect a yesterday\'s datapoint if it does not exist', async () => { const getMetricDataStub = sinon.stub(MockService.prototype, 'getMetricData').returns([]) const params = generateConstructorParams() const metric = new Metric(params) metric.calculateUncollectedDates = () => 1 await metric.collect() assert(getMetricDataStub.calledTwice) const argsAtSecondCall = getMetricDataStub.args[1] const actualBegin = argsAtSecondCall[2] const actualEnd = argsAtSecondCall[3] const now = new Date() assert(actualBegin.getTime() === new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1).getTime()) assert(actualEnd.getTime() === new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime()) })