Added !when command
This commit is contained in:
parent
6947fb843e
commit
4151ab95f8
6 changed files with 159 additions and 6 deletions
50
helpers/dates.js
Normal file
50
helpers/dates.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
const moment = require('moment')
|
||||
|
||||
module.exports = {
|
||||
setPeriod: (period) => {
|
||||
switch (period) {
|
||||
case 'day':
|
||||
return {
|
||||
$gte: moment().startOf('day'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'week':
|
||||
return {
|
||||
$gte: moment().startOf('week'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'month':
|
||||
return {
|
||||
$gte: moment().startOf('month'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'year':
|
||||
return {
|
||||
$gte: moment().startOf('year'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'lastday':
|
||||
return {
|
||||
$gte: moment().subtract('day').startOf('day'),
|
||||
$lte: moment().subtract('day').endOf('day')
|
||||
}
|
||||
case 'lastweek':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'week').startOf('week'),
|
||||
$lte: moment().subtract(1, 'week').endOf('week')
|
||||
}
|
||||
case 'lastmonth':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'month').startOf('month'),
|
||||
$lte: moment().subtract(1, 'month').endOf('month')
|
||||
}
|
||||
case 'lastyear':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'year').startOf('year'),
|
||||
$lte: moment().subtract(1, 'year').endOf('year')
|
||||
}
|
||||
default:
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
8
helpers/strings.js
Normal file
8
helpers/strings.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
formatString: function (string) {
|
||||
if (string !== undefined && string !== null) {
|
||||
return new RegExp('^' + string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + '$', 'i')
|
||||
}
|
||||
return ';'
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue