Published
Edited
Jun 6, 2019
1 fork
Insert cell
md`# RRULEs`
Insert cell
luxon = import('https://unpkg.com/luxon@1.16.0/src/luxon.js?module')
Insert cell
rrule = import('https://unpkg.com/rrule@2.6.0/dist/esm/src/index.js?module')
Insert cell
frequency = ({
YEARLY: 0,
MONTHLY: 1,
WEEKLY: 2,
DAILY: 3,
HOURLY: 4,
MINUTELY: 5,
SECONDLY: 6,
})
Insert cell
weekdays = ({
Sunday: rrule.RRule.SU,
Monday: rrule.RRule.MO,
Tuesday: rrule.RRule.TU,
Wednesday: rrule.RRule.WE,
Thursday: rrule.RRule.TH,
Friday: rrule.RRule.FR,
Saturday: rrule.RRule.SA
})
Insert cell
weekdays['Sunday']
Insert cell
md`# Define Variables`
Insert cell
freq = frequency['WEEKLY']
Insert cell
interval = undefined
Insert cell
dtstart = new Date(Date.UTC(2019, 6, 6, 14, 30))
Insert cell
until = undefined
//until = new Date(Date.UTC(2019, 6, 6, 14, 30))
Insert cell
wkst= undefined
Insert cell
count = undefined
Insert cell
tzid = undefined
Insert cell
bysetpos = undefined
Insert cell
bymonth = undefined
Insert cell
byyearday = undefined
Insert cell
byweekno = undefined
Insert cell
byweekday = [weekdays["Monday"],weekdays["Tuesday"],weekdays["Thursday"],weekdays["Friday"]]
Insert cell
byhour = [14]
Insert cell
byminute = [30]
Insert cell
bysecond = [0]
Insert cell
bymonthday = undefined
Insert cell
betterRule = new rrule.RRule({
...freq && { freq: freq }, //YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY
...interval && { interval: interval }, //The interval between each freq iteration.
...dtstart && { dtstart: dtstart }, // The recurrence start.
...until && { until: until }, //this must be a Date instance, that will specify the limit of the recurrence
...wkst && { wkst: wkst }, // An integer, specifying the first day of the week. The default week start is RRule.MO
...count && { count: count }, // How many occurrences will be generated.
...tzid && { tzid: tzid }, // Luxon string
...bysetpos && { bysetpos: bysetpos }, //For example, a bysetpos of -1 if combined with a RRule.MONTHLY frequency, and a byweekday of (RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR), will result in the last work day of every month.
...bymonth && { bymonth: bymonth }, //Integer. the months to apply the recurrence to.
...bymonthday && { bymonthday: bymonthday }, //Integer. the month days to apply the recurrence to.
...byyearday && { byyearday: byyearday }, //Integer. the year days to apply the recurrence to.
...byweekno && { byweekno: byweekno }, //Integer. the week numbers to apply the recurrence to.
...byweekday && { byweekday: byweekday }, //Integer.
...byhour && { byhour: byhour }, //Integer. the hours to apply the recurren
...byminute && { byminute: byminute }, //Integer. the minutes to apply the recurrence to.
...bysecond && { bysecond: bysecond }, //Integer. the seconds to apply the recurrence to.
})
Insert cell
betterRule.between(new Date(Date.now()), new Date(Date.UTC(2020, 6, 6)))
Insert cell
betterRule.toString()
Insert cell
betterRuleFromString = rrule.RRule.fromString(betterRule.toString())
Insert cell
// betterRuleFromString.all()
Insert cell
new rrule.RRule({
dtstart: new Date(Date.UTC(2018, 1, 1, 10, 30)),
count: 1,
tzid: 'Asia/Tokyo'
}).all()
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more