Skip to contents

Check that the type of a given time matches the time type of a given forecast.

Usage

validate_time(t, fcst)

Arguments

t

A time (e.x. a number, date, or date-time).

fcst

A forecast object (see output of create_forecast()).

Value

NULL if t is compatible with fcst. Error otherwise

Examples

# both numeric (compatible)
casteval:::validate_time(5, create_forecast(data.frame(time=6,val=7)))
#> NULL

# one date, one date-time (incompatible)
try(casteval:::validate_time(
  lubridate::ymd("2024-01-01"),
  create_forecast(data.frame(time=lubridate::ymd_hms("2024-01-01_00:00:00"),val=6))
))
#> Error in casteval:::validate_time(lubridate::ymd("2024-01-01"), create_forecast(data.frame(time = lubridate::ymd_hms("2024-01-01_00:00:00"),  : 
#>   type of `t` does not match `fcst$time_type`