Learn R Programming

tind (version 0.2.4)

jdn: Date and Date-Time Conversion to and from Julian Day Number (JDN)

Description

jdn computes the JDNs for dates or date-time indices and jdn2tind returns dates or date-time indices given JDNs.

For date arguments jdn returns the numbers of days since November 24, 4714 BC in the proleptic Gregorian calendar as an integer vector. For date-time arguments day fraction in UTC is computed and the return value is a numeric vector.

For integer arguments jdn2tind return tind of type "d" (date), for non-integer arguments --- tind of type "t" (date-time). If tz argument is provided the return value is always of type "t" (date-time).

Usage

jdn(x)

jdn2tind(x, tz = NULL)

Value

An integer or numeric vector for jdn, an object of tind class (type "d" or "t") for jdn2tind.

Arguments

x

an object of tind class or an R object coercible to it for jdn, an integer or numeric vector for jdn2tind.

tz

(optional) a character value determining the time zone (the default NULL is interpreted as the system time zone). See tzone documentation for information on time zones.

See Also

date2num for conversion between dates and their integer representations found different software packages.

Examples

Run this code
# JDN of 2000-01-01 is 2451545
jdn("2000-01-01")
jdn2tind(2451545)
# JDN today, now?
jdn(today())
jdn(now())
# notice the .5 offset
jdn(today(tz = "UTC"))
format(jdn(as.date_time(today(tz = "UTC"), tz = "UTC")), digits = 8)

Run the code above in your browser using DataLab