Platform
Solutions
Resources
Pricing
Sign in
Sign up
Andrew Agostini
Workspace
Fork
Published
By
Andrew Agostini
Edited
Jun 16, 2019
Insert cell
md
`# rrule.js`
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
// Create a rule:
rule
=
new
rrule
.
RRule
(
{
freq
:
rrule
.
RRule
.
WEEKLY
,
dtstart
:
new
Date
(
Date
.
UTC
(
2014
,
10
,
2
,
0
,
0
)
)
,
///2014-11-02
until
:
new
Date
(
Date
.
UTC
(
2019
,
12
,
31
,
0
,
0
)
)
}
)
Insert cell
rule
.
toString
(
)
Insert cell
durationHours
=
24
Insert cell
// START TIMES
rule
.
all
(
)
Insert cell
// ENDTIMES
rule
.
all
(
)
.
map
(
date
=>
luxon
.
DateTime
.
fromJSDate
(
date
)
.
toUTC
(
)
.
plus
(
{
hours
:
durationHours
}
)
.
setZone
(
'local'
,
{
keepLocalTime
:
true
}
)
.
toJSDate
(
)
)
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.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
luxon
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rrule
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rule
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
durationHours
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML