more fCalendar
If you have not received a reply to this and your other similar post, I suggest you send a private email to the Maintainer: Diethelm Wuertz <wuertz at itp.phys.ethz.ch>. I would think he would appreciate your contribution. Good Luck, spencer graves
Parlamis Franklin wrote:
It's me again, with Japanese calendar minutiae I'm sure you've all
been dying to brush up on.
the fCalendar functions don't include the Japanese Vernal Equinox
holiday. this is perhaps because there is no easy way to calculate
it. at any rate, here's a function i wrote to fill the gap.
=====
JPVernalEquinox <- function(year) {
## Origin and End Date data from http://aa.usno.navy.mil/data/
docs/EarthSeasons.html
## The function Vernal.Equinox delivers correct values at the
endpoints of the above data.
## There may be minor variances (+/- a few minutes) in the
intermediate values,
## because the function linearly approximates a phenomenon that
is apparently
## nonlinear in recorded time.
Equinox.Origin <- timeCalendar(1992, 3, 20, 8, 48, 0,
FinCenter="GMT")
Data.EndDate <- timeCalendar(2020,3,20,3,49,0,FinCenter="GMT")
Total.Seconds <- as.numeric(Data.EndDate-Equinox.Origin)*24*60*60
Mean.Annual.Seconds <- Total.Seconds/(atoms(Data.EndDate)$Y-atoms
(Equinox.Origin)$Y)
Vernal.Equinox <- function(year) Equinox.Origin+unclass((year-
atoms(Equinox.Origin)$Y)*Mean.Annual.Seconds)
JPVernal.Equinox <- function(year) timeDate(as.character
(Vernal.Equinox(year)), FinCenter="Tokyo")
## Nota bene: JP Vernal Equinox is celebrated when the equinox
occurs in the Japanese time zone
## (see, e.g., 2006, where GMT Vernal Equinox is on 20 March,
but Japanese Equinox holiday is 21 March)
as.Date(as.character(JPVernal.Equinox(year)))}
=====
in contrast to the other holiday functions in fCalendar, the above
function returns an object of class "Date" rather than "sdate"
because use of sdates appears to be deprecated following the
introduction of the Date class, and also because the sdate function
appears to have a bug.
[[alternative HTML version deleted]]
_______________________________________________ R-sig-finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA spencer.graves at pdf.com www.pdf.com <http://www.pdf.com> Tel: 408-938-4420 Fax: 408-280-7915