Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 3 4 5 6 7 8 | OtherDate(day, month, year, calendar)
as.OtherDate(x,calendar,...)
## S3 method for class 'OtherDate'
as.Date(x,...)
## S3 method for class 'Date'
as.OtherDate(x,calendar,...)
## Default S3 method:
as.OtherDate(x,calendar,...)
|
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 |
... |
Not used. |
"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.
An object of class OtherDate
or Date
as appropriate.
Thomas Lumley
http://www.projectpluto.com/calendar.htm is the source for the conversion code and documentation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.