Skip to content

Commit

Permalink
Fix bug Alex was having
Browse files Browse the repository at this point in the history
  • Loading branch information
akgold committed Mar 21, 2019
1 parent ff03024 commit b4b6404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: gcalendr
Type: Package
Title: Read Events From Google Calendar
Version: 0.0.1.9000
Version: 0.0.1.9001
Authors@R: c(person("Andrie", "de Vries", role=c("aut", "cre"), email="[email protected]"))
Description: Read events from the Google Calendar API.
Date: 2017-12-13
Expand All @@ -22,5 +22,5 @@ Imports:
dplyr,
lubridate,
tidyr
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
Roxygen: list(markdown = TRUE)
13 changes: 7 additions & 6 deletions R/read_google_calendar.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,17 @@ get_gcal_events <- function(id, google_token, max_results = 250, days_in_past =

events %>%
mutate(
created = as_datetime(created),
updated = as_datetime(updated),
start_date = if ("start_date" %in% names(.)) as_date(start_date) else as_date(NA),
end_date = if ("end_date" %in% names(.)) as_date(end_date) else as_date(NA),
created = transform_or_na(., "created", as_datetime),
updated = transform_or_na(., "updated", as_datetime),
start_date = transform_or_na(., "start_date"),
end_date = transform_or_na(., "end_date"),
start_dateTime = as_datetime(start_dateTime),
end_dateTime = as_datetime(end_dateTime)
)
}



transform_or_na <- function(df, varname, fn = as_date) {
if (varname %in% names(df)) df %>% pull(!!varname) %>% fn() else fn(NA)
}


Expand Down

0 comments on commit b4b6404

Please sign in to comment.