ConvCalendar (version 1.2)

OtherDate: Calendar conversions

Description

OtherDate() creates an object of class OtherDate containing day, month, year, and calendar. This has methods to convert to and from Date, and will attempt to convert from any other type by coercing to Date first.

Usage

OtherDate(day, month, year, calendar) as.OtherDate(x,calendar,...) "as.Date"(x,...) "as.OtherDate"(x,calendar,...) "as.OtherDate"(x,calendar,...)

Arguments

day
numeric vector, day of the month
month
numeric vector, month number
year
numeric vector, year
calendar
a single character string that is partial-matched to "gregorian", "julian","hebrew","islamic","frenchrev","persian","modpersian"
x
A Date or OtherDate object as appropriate
...
Not used.

Value

An object of class OtherDate or Date as appropriate.

Details

"persian" is the Jalali calendar, "modpersian" is the modern Persian calendar (which has regularised leap years). These are accurate only from 475BCE to 2948CE.

Technically the Islamic calendar depends on actual sighting of the crescent moon and so cannot be projected into the future. In practice, a reliable guide to the calendar has alternating months of 29 and 30 days, with a leap day at the end of year in 11 years out of 30. This is used by the "islamic" converter. The converter has 1-1-1 as 16 July 622CE; some sources use 15 July of that year.

The French Revolutionary calendar is essentially pointless, since it was only used for 14 years and there is a bug it how it was originally defined -- the specifications of having a leap year every fourth year and having the year start on the autumn equinox are incompatible.

References

http://www.projectpluto.com/calendar.htm is the source for the conversion code and documentation.

See Also

date, as.Date

Examples

Run this code

persian <- OtherDate(day=1:20, month=10, year=1385, calendar="persian")
persian

gregorian<-as.Date(persian)
gregorian

as.OtherDate(gregorian,"persian")

as.OtherDate(gregorian,"islamic")

as.OtherDate(gregorian,"hebrew")

## from POSIXct
as.OtherDate(.leap.seconds, "persian")

## Not run: 
# ## from character string in Gregorian date,
# ##   (depends on month names in your locale)
# as.OtherDate("14jun1969",format="%d%b%Y", "hebrew")
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace