Skip to content

Commit

Permalink
add new dates and processing code for calendar events
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjohnst86 committed Nov 28, 2022
1 parent dbf58f9 commit cec8d27
Showing 1 changed file with 29 additions and 39 deletions.
68 changes: 29 additions & 39 deletions R/add-to-calendar.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source(here::here("R/functions.R"))
# library(assertr)
library(tidyverse)
library(lubridate)
Expand All @@ -7,49 +8,38 @@ library(glue)
stop("This prevents accidentally sourcing the whole script.")

meeting_dates <- tribble(
~month, ~day,
"January", 9,
"February", 6,
"March", 6,
"March", 24,
"May", 1,
"June", 5,
"September", 4,
"October", 9,
"November", 6,
"December", 4
) %>%
mutate(
year = "2023",
date = ymd(glue("{year}-{month}-{day}"), tz = "Europe/Copenhagen"),
start_time = "13:00",
end_time = "15:00"
)
~month, ~day,
"January", 9,
"February", 6,
"March", 6,
"March", 24,
"May", 1,
"June", 5,
"September", 4,
"October", 9,
"November", 6,
"December", 4
) %>%
mutate(
year = "2023",
date = ymd(glue("{year}-{month}-{day}"), tz = "Europe/Copenhagen"),
start_time = "13:00",
end_time = "15:00"
)

upcoming_meetings <- meeting_dates %>%
transmute(
UID = map_chr(1:n(), ~ ic_guid()),
DTSTART = ymd_hm(glue("{date} {start_time}"), tz = "Europe/Copenhagen"),
DTEND = ymd_hm(glue("{date} {end_time}"), tz = "Europe/Copenhagen"),
# To show up as the event description
DESCRIPTION = "Details about the meeting are found on the Trello board: https://trello.com/b/ipcYGXhC/epidemiology-group",
# To show up as the event title
SUMMARY = "Steno Aarhus Epidemiology Group Monthly Meeting"
)
transmute(
UID = map_chr(1:n(), ~ ic_guid()),
DTSTART = ymd_hm(glue("{date} {start_time}"), tz = "Europe/Copenhagen"),
DTEND = ymd_hm(glue("{date} {end_time}"), tz = "Europe/Copenhagen"),
# To show up as the event description
DESCRIPTION = "Details about the meeting are found on the Trello board: https://trello.com/b/ipcYGXhC/epidemiology-group",
# To show up as the event title
SUMMARY = "Steno Aarhus Epidemiology Group Monthly Meeting"
)

public_calendar_link <- "https://calendar.google.com/calendar/ical/086okoggkv7c4b0dcbbrj230s8%40group.calendar.google.com/public/basic.ics"
read_lines(public_calendar_link) %>%
ic_list() %>%
map_dfr(ic_vector) %>%
names()
mutate(across(matches("VALUE=DATE"),
~ic_date))
current_calendar <- ic_read(public_calendar_link) %>%
mutate(
DTSTART = with_tz(ymd_hms(DTSTART), "Europe/Copenhagen"),
DTEND = with_tz(ymd_hms(DTEND), "Europe/Copenhagen")
) %>%
arrange(DTSTART) %>%
current_calendar <- read_ical(public_calendar_link) %>%
select(DTSTART, DTEND, SUMMARY)

new_calendar_data <- anti_join(upcoming_meetings, current_calendar)
Expand Down

0 comments on commit cec8d27

Please sign in to comment.