Generate Dates

DESCRIPTION:

Generate a dates object from integer or character string representations of dates.

USAGE:

dates(x, format = "m/d/y", out.format, origin, century) 
origin(date) 

REQUIRED ARGUMENTS:

x
a dates object, a character vector, or a numeric vector specifying dates. If character, it must be in the format specified by the format argument. If numeric, it specifies Julian dates, that is, number of days since an origin.
date
an object of class "dates".

OPTIONAL ARGUMENTS:

format
a character string giving the format for interpreting x when x is a vector or character strings. See the DETAILS section for the possible formats. Default is "m/d/y".
out.format
a character string giving the format for printing the resulting dates object. Default is "m/d/year".
origin
a vector of length 3 specifying the date with respect to which Julian dates are computed. Default is c(month=1, day=1, year=1960), that is, January 1, 1960.
century
integer specifying the starting year for the 100-year period that 2-digit dates represent. The default value of 1930 means that 2-digit dates run from 1930 to 2029, so that, for example, "1/1/45" is in 1945 and "1/1/22" is 2022.

VALUE:

The dates function returns an object of class "dates"; that is, an object with a format attribute determined by out.format, an origin attribute as specified by the argument origin , and class attribute "dates".

The origin function extracts the origin of an object of class "dates".

DETAILS:

The character strings for format and out.format can be any permutation of the following characters: "d" or "day" (two digit number); "m" (two digit number, for example, 11), "mon" (three-letter abbreviation, e.g., Nov) or "month" (full month name, for example, November); and "y", "yy" (two digit number, for example, 93) or "yr", "year" (four digit number, for example, 1993), separated by a single character ( "/", ".", "-" or a space) delimiter with special cases: "mdy", "dmy" and "ymd". All 3 letters or words must be present. The same separators must be used and consistent with those in x when x is a character string. Thus "d-m-y", "month day year", and "day month year" are all valid.

Different separators can be specified in out.format and the first one will be used.

SEE ALSO:

, , , .

EXAMPLES:

tday <- dates("23/7/04", format="d/m/y", out="day mon year") 
tday 
# produces the following output: 
#[1] 23 Jul 2004 
origin(tday) 
# produces the following output: 
#month day year 
#    1   1 1960 
dates("7/23/04", out="mon/d/year", century=1900) 
# produces the following output: 
#[1] Jul/23/1904