date_to_api: Convert String or Date to API Input

Description Usage Arguments Value Examples

Description

This function converts dates from a human-consumable format (e.g. 2008-12-15) to their equivalent time in seconds since the Unit Epoch (1970-01-01 00:00:00 UTC), which is how Pushshift's API expects dates.

Usage

1
date_to_api(date, tz = "")

Arguments

date

A date (which can be a string representing a validly formatted date or one of the Date types) to compare to the Unit epoch, granular down to seconds.

tz

The timezone of the date to compare, defaults to system's timezone for direct use.

Value

A string representing a time (in seconds) that the api can use to return results.

Examples

1
2
3
4
5
6
7
8
# convert today
date_to_api(Sys.Date())

# convert a specific date
date_to_api("2018-03-21")

# pass as argument to construct_pushshift_url
construct_pushshift_url(before = date_to_api("2017-01-01"))

geoffwlamb/redditr documentation built on May 15, 2019, 11:41 a.m.