DateTime::Util::Astro::Moon - Functions To Calculate Lunar Data
use DateTime::Util::Astro::Moon qw(nth_new_moon lunar_phase lunar_longitude); my $dt = nth_new_moon(24773); # should be 2003/12/23 UTC my $phase = lunar_phase($dt); my $longitude = lunar_longitude($dt);
This module provides functions to calculate lunar data, but its main focus is to provide just enough functionality that allows us to create lunisolar calendars and other DateTime related modules.
This module is a *straight* port from "Calendrical Calculations" [1] -- and therefore there are places where things can probably be "fixed" so that they look more like Perl, as well as places where we could leverage the DateTime functionalities better. If you see things that doesn't quite look right (in Perl), that's probably because of that.
Before you use this module, please be aware that this module was originally created solely for the purpose of creating a lunisolar calendar for the DateTime project (http://datetime.perl.org).
We used [1] as basis for our calculations. While for most purposes the results are accurate enough, you should note that the calculations from this book are approximations.
Obviously we would like to make this module as good as possible, but there's only so much you can do in the accuracy department. However, having GMP and Math::BigInt::GMP may help a little bit.
This module by default uses Perl's arbitrary precision calculation module Math::BigFloat. However, this adds a fair amount of overhead, and you will see a noticeable difference in execution speed. This is true even if you use GMP.
DateTime::Util::Astro::Moon can use Cache::FileCache to cache results of certain functions.
This is always turned on. For example, nth_new_moon() is basically a constant function for the given n, and therefore should not need to recalculate values ever again.
n
DateTime::Util::Astro::Moon uses Cache::Cache for its cache intetface, and by defaults to using Cache::FileCache. If you would like to use a different type of cache, or tweak its behavior, you can either assign or call methods on this variable:
$DateTime::Util::Astro::Moon::CACHE
For example, if you want to forcibly expire this cache, do this:
$DateTime::Util::Astro::Moon::CACHE->purge();
Or use a memory cache instead
$DateTime::Util::Astro::Moon::CACHE = Cache::MemoryCache->new( ... args ... );
The mean time between new moons
Given a DateTime object $dt, calculates the lunar longitude.
Given a DateTime object $dt, calculates the lunar phase (in degrees)
Given an integer $n, returns a DateTime object representing the moment of $n-th new moon after R.D. 0. The 0th new moon was on January 11, 1 (Gregorian)
Daisuke Maki <daisuke@cpan.org>
[1] Edward M. Reingold, Nachum Dershowitz "Calendrical Calculations (Millenium Edition)", 2nd ed. Cambridge University Press, Cambridge, UK 2002
DateTime DateTime::Event::Lunar DateTime::Event::SolarTerm DateTime::Util::Astro::Common DateTime::Util::Astro::Sun
To install DateTime::Util::Astro::Sun, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::Util::Astro::Sun
CPAN shell
perl -MCPAN -e shell install DateTime::Util::Astro::Sun
For more information on module installation, please visit the detailed CPAN module installation guide.