tojulian {CTFS}R Documentation

Converts Calendar Dates to Julian Dates and Back

Description

These two functions can be used to convert dates to and from julian formats for computations. There are many functions that do this but these are useful for CTFS. The functions rely upon functions found in the R package survival.

Usage

tojulian(x, dateform = "%m/%d/%Y", centurycut = 2020)
fromjulian(j, dateform = "%m/%d/%Y")

Arguments

x calendate date in the default format “m/d/yyyy”. The year should be specified with the century included, eg. “12/4/1999”
j the number of days since 1/1/1960
dateform format for calendar date, see strptime for format information
centurycut years after this date are assumed to be in the 21st century

Details

These functions are dependent upon the package survival. They use the functions mdy.date and date.mmddyyy.

The results of tojulian is a number of days, so it is an integer and can be used for computation.

Value

tojulian returns an integer, the number of days since 1/1/1960 formatted as d/m/y where d = day, m = 3 letter abreviation for month eg Jan, Feb, Mar..., and y = year.
fromjulian returns a calendar date in mm/dd/yyyy format

Author(s)

Rick Condit

References

depends on the package survival

See Also

CTFS.utilities

Examples

## Not run: 
1.  tojulian()

x1="3/5/1987"
x2="3/5/2001"
y1 <- tojulian(x1)
y2 <- tojulian(x2)
str(y1)
str(y2)
y2-y1

2.  fromjulian()
fromjulian(9925)
fromjulian(15039)
fromjulian(y1+(y2-y1))
  ## End(Not run)

[Package CTFS version 1.00 Index]