jdn: Date and Date-Time Conversion to and from Julian Day Number...

View source: R/calendar.R

jdnR Documentation

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)

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.

Value

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

Note

For date-time indices JDN is computed based on day fraction since noon UTC and not midnight, so 0.5 offset will be observable.

See Also

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

Examples

# 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)


tind documentation built on Dec. 28, 2025, 1:06 a.m.