Astro-MoonPhase-Simple
view release on metacpan or search on metacpan
lib/Astro/MoonPhase/Simple.pm view on Meta::CPAN
# timezone : optional timezone as a TZ identifier e.g. Africa/Abidjan
# location : optionally deduce timezone from location if above timezone is absent,
# it is a nameplace string, e.g. 'Abidjan'
# OR it is a HASHref with keys 'lat' and 'lon'
# verbosity: optionally specify a positive integer to increase verbosity, default is zero for no verbose messages (only errors and warnings)
# Returns:
# a hash with results including 'asString' which contains a string description of the results.
# or undef on failure
sub calculate_moon_phase {
my $params = $_[0];
my $parent = ( caller(1) )[3] || "N/A";
my $whoami = ( caller(0) )[3];
if( ! defined($params) || ref($params) ne 'HASH' ){
print STDERR "$whoami (via $parent) : parameters in the form of a HASHref are required.";
return undef
}
my $verbosity = exists($params->{'verbosity'}) && defined($params->{'verbosity'}) ? $params->{'verbosity'} : 0;
if( exists($params->{'date'}) && defined($params->{'date'}) ){
if( $params->{'date'} !~ /^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/ ){
print STDERR "$whoami (via $parent) : parameter 'date' does not parse YYYY-MM-DD : ".$params->{'date'}."\n";
( run in 0.915 second using v1.01-cache-2.11-cpan-b61123c0432 )