Learn R Programming

charlatan (version 0.6.1)

DateTimeProvider: DateTimeProvider

Description

date and time methods

Arguments

Super class

charlatan::BareProvider -> DateTimeProvider

Public fields

centuries

(character) centuries in roman numerals

countries

(list) countries list

Methods

Inherited methods


Method unix_time()

Get a timestamp between January 1, 1970 and now, unless passed explicit start_date or end_date values

Usage

DateTimeProvider$unix_time(start_date = NULL, end_date = "now")

Arguments

start_date

start date, a valid date format

end_date

start date, a valid date format, default: "now"


Method date()

Generate a date between January 1, 1970 and now, with given pattern

Usage

DateTimeProvider$date(pattern = "%Y-%m-%d")

Arguments

pattern

date pattern, default: %Y-%m-%d


Method date_time()

Generate a date time between January 1, 1970 and now

Usage

DateTimeProvider$date_time(tzinfo = NULL)

Arguments

tzinfo

timezone, see timezone


Method date_time_fromtimestamp()

Generate a iso8601 format date

Usage

DateTimeProvider$date_time_fromtimestamp(timestamp, tzinfo = NULL)

Arguments

timestamp

a timestamp

tzinfo

timezone, see timezone


Method iso8601()

Generate a iso8601 format date

Usage

DateTimeProvider$iso8601(date, tzinfo = NULL)

Arguments

date

a date, in a valid date format

tzinfo

timezone, see timezone


Method year()

generate a year

Usage

DateTimeProvider$year()


Method century()

generate a century

Usage

DateTimeProvider$century()


Method timezone()

generate a timezone

Usage

DateTimeProvider$timezone()


Method date_time_between()

Generate a date time based on a random date between two given dates

Usage

DateTimeProvider$date_time_between(start_date, end_date = "now", tzinfo = NULL)

Arguments

start_date

start date, a valid date format

end_date

start date, a valid date format, default: "now"

tzinfo

timezone, see timezone


Method clone()

The objects of this class are cloneable with this method.

Usage

DateTimeProvider$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

References

https://en.wikipedia.org/wiki/Unix_time

https://en.wikipedia.org/wiki/Unix_time

Examples

Run this code
z <- DateTimeProvider$new()
z$countries
z$centuries
z$century()
z$timezone()
z$unix_time()
z$date("%Y-%M-%d")
z$date_time()
z$year()
z$iso8601("1932-02-12 05:32:12")
# z$iso8601("January 4, 1981")

# date time between a range of dates
(start_date <- Sys.time() - 604800L)
z$date_time_between(start_date = start_date)
# in the year 1900
z$date_time_between("1900-01-01 00:00:00 PST", "1900-12-31 00:00:00 PST")
z$date_time_between("1900-01-01", "1900-12-31")

Run the code above in your browser using DataLab