Do timescales through pure functions which create regexes for timestamps and filter that way
function returns a generated validator(): bool for 'this month', then filter data: data.filter(validator). Internally, it more or less runs const validator = s => /^2020/.test(s).
- This month -
/^2020-05/.test(timestamp)
- Last 90 days - this can be done with regex but it should return a function which does some more involved logic and returns boolean (for filtering)
- Last 6 months -
/^2020/.test(timestamp)
- This year -
/^2020/.test(timestamp)
- Last year -
/^2019/.test(timestamp) (this year - 1)
- All-time - true
Do timescales through pure functions which create regexes for timestamps and filter that way
function returns a generated
validator(): boolfor 'this month', then filter data:data.filter(validator). Internally, it more or less runsconst validator = s => /^2020/.test(s)./^2020-05/.test(timestamp)/^2020/.test(timestamp)/^2020/.test(timestamp)/^2019/.test(timestamp)(this year - 1)