Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. check_input <- function(token, start_date) {
  2. # parameter validation
  3. if ( !"token" %in% ls() ) {
  4. stop("All regular API requests require a token. Use get_token() to get one")
  5. } else if (expire_time < Sys.time()) {
  6. stop("All API tokens expire after an hour. Use get_token() to get one")
  7. } else if ( is.numeric(latitude) == FALSE | is.numeric(latitude) == FALSE ) {
  8. stop("Latitude and longitude has to be decimal-formatted numbers")
  9. } else if ( !lubridate::is.Date(as.Date(start_date, "%Y-%m-%d")) ) {
  10. stop("Start date has to be ISO-8601 formatted date in format: YYYY-MM-DD")
  11. } else {
  12.  
  13. # heads up about forecast data
  14. forecast <- as.numeric(Sys.Date() - as.Date(start_date)) + 1
  15.  
  16. if ( forecast < 9 ) cat("The result will include", 8 - forecast, "days of forecasting data\n")
  17.  
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement