Created
June 12, 2020 01:56
-
-
Save SimonCoulombe/619a1dd1327456ea42f2d8c28ea28709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_github_file_commit_date <- function(repo, filepath){ | |
url <- paste0("https://api.github.com/repos/", | |
repo, | |
"/commits?path=", | |
gsub("/", "/%2F", filepath), | |
"&page=1&per_page=1") | |
request <- httr::GET(url, httr::user_agent("httr")) | |
content <- httr::content(request) | |
content[[1]]$commit$committer$date | |
} | |
get_local_file_date <- function(filepath){ | |
file.info(filepath)$ctime | |
} | |
github_file_commit <- get_github_file_commit_date("ishaberry/covid19canada", | |
"timeseries_hr/cases_timeseries_hr.csv") | |
local_file_time <- get_local_file_date("~/git/adhoc_prive/covid19_PNG/canada_cases.png") | |
timediff <- local_file_time - lubridate::ymd_hms(github_file_commit) | |
print(timediff) | |
# Time difference of 16.60829 mins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment