aboutsummaryrefslogtreecommitdiff
path: root/src/lib/rule_generator.js
blob: 6958beca80cc687f74967ab30e0e2f1927c34e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Rules from './rules';

const internals = {

  dates: [
    'today',
    'tomorrow',
    'next friday',
    'next wednesday',
    'last thursday',
    'last tuesday',
    'the next day divisible by 7',
    'this afternoon',
    'next fiscal quarter',
  ],

  rules: [
		...Rules
	],
  currentIndex: 0
}

export const generate = async function () {

	const rule = internals.rules[internals.currentIndex];
	const time = internals.dates[Math.floor(Math.random() * internals.dates.length)];
	internals.currentIndex = (internals.currentIndex + 1) % internals.rules.length
	return {
		rule: rule(),
		time
	}
}