Take a datetime representation in R and convert it to the list required by DFP to indicate a datetime

dfp_date_to_list(this_date, daytime = c("beginning", "end"),
  timeZoneId = Sys.timezone(), ensure_today_works = TRUE)

Arguments

this_date

Date; formatted as Date, POSIXct, or POSIXlt

daytime

character; either "beginning" or "end" so that the function knows which hours to set if needed

timeZoneId

character; a string indicating the timezone that should be used. The timezone ID must be in Time_Zone database

ensure_today_works

logical; an indicator that will automatically offset the current time by 1 hour so that forecasts will actually work. If you try to forecast from a timestamp of now, then by the time you submit it to the ForecastService it will already be too late to be in the future.

Value

a list formatted to the spec required for StartDateTime or EndDateTime

Examples

dfp_date_to_list(Sys.Date()+1)
#> The date provided is not at least 1 hour into the future. Setting to one hour after now.
#> $date #> $date$year #> [1] 2019 #> #> $date$month #> [1] 6 #> #> $date$day #> [1] 5 #> #> #> $hour #> [1] 20 #> #> $minute #> [1] 51 #> #> $second #> [1] 45 #> #> $timeZoneId #> [1] "America/New_York" #>