get_required_date_ranges: Get required date ranges to be requested

Description Usage Arguments Details Value Examples

View source: R/helpers.R

Description

Function takes a vector of dates, a start and end date, and returns a list of adjacent date sequences that are not covered by the vector of dates.

Usage

1
get_required_date_ranges(.dates, .since, .until)

Arguments

.dates

a vector of dates or NULL, defining the (start and/or end) dates taken as given. Alternatively, .dates can be a vector of integer values that will be converted to dates using as_date (hence, origin, that is, '1970-01-01 UTC' will be used as origin date).

.since

a date (format '%Y-%m-%d'), specifying the start of the date range to be requested

.until

a date (format '%Y-%m-%d'), specifying the end of the date range to be requested

Details

This function is an internal helper. All dates need to be in YYYY-mm-dd ('%Y-%m-%d') format.

Value

Either of the following two

  1. A list of date range start and end dates in the date range spaned from .since to .until that is not covered by dates in .dates.

  2. NULL if length of dates is zero, or the requested time range is convered by the date range spaned from .since to .until.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dates <- seq(Sys.Date()-30, Sys.Date()-5, by = "day")
since <- Sys.Date() -35
until <- Sys.Date()

# returns list with one date range vector (spanning since - until)
twscrape:::get_required_date_ranges(NULL, since, until)

# returns list with two date range vectors
twscrape:::get_required_date_ranges(Sys.Date()-1, since, until)

# returns list with two date range vectors
twscrape:::get_required_date_ranges(dates, since, until)

haukelicht/twscrape documentation built on Jan. 29, 2020, 3:23 p.m.