Convert between Julian and Calendar Dates

DESCRIPTION:

Converts Julian dates to calendar dates and vice versa.

USAGE:

julian(m, d, y, origin=c(month=1, day=1, year=1960)) 
month.day.year(jul, origin=c(month=1, day=1, year=1960)) 
leap.year(y) 
day.of.week(m, d, y) 

REQUIRED ARGUMENTS:

m
vector of month numbers.
d
vector of day numbers.
y
vector of years. The years should be entered in their full four-digit form; it is assumed that two-digit years refer to the first century.
jul
vector of Julian dates (the number of days since origin).

OPTIONAL ARGUMENTS:

origin
vector specifying the month, day, and year of the origin. If origin is missing, it defaults to options(chron.origin) if this is not NULL, and c(month=1, day=1, year=1960) otherwise.

VALUE:

When julian is called, a vector of Julian dates corresponding to the input values is returned. If month.day.year is called, a list with members month, day, and year is returned, corresponding to the given Julian dates. The leap.year function returns a logical vector indicating whether the input years are leap years. The day.of.week function returns a number between 0 and 6 that specifies the day of the week of the given date; 0 refers to Sunday.

These functions are taken from Becker, Chambers, and Wilks (1988), and were slightly modified to include origin arguments and accept dates objects. The original functions are stored in library(examples).

SEE ALSO:

, .

EXAMPLES:

# The number of days from January 1, 1990 to each of:
#     January 15, 1990
#     February 15, 1991
#     March 15, 1992
#     etc.
n.days <- julian(1:12, rep(15,12), 1990+(0:11), origin=c(1,1,1990))
# November 12, 98, was a Wednesday.
day.of.week(m = 11, d = 12, y = 98)
# November 12, 1998, was a Thursday.
day.of.week(m = 11, d = 12, y = 1998)