Date-Darian-Mars
    
    
  
  
  
view release on metacpan or search on metacpan
{
   "abstract" : "the Darian calendar for Mars",
   "author" : [
      "Andrew Main (Zefram) <zefram@fysh.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Module::Build version 0.4224",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'the Darian calendar for Mars'
author:
  - 'Andrew Main (Zefram) <zefram@fysh.org>'
build_requires:
  Module::Build: '0'
  Test::More: '0'
  perl: '5.006'
  strict: '0'
  warnings: '0'
configure_requires:
  Module::Build: '0'
NAME
Date::Darian::Mars - the Darian calendar for Mars
DESCRIPTION
The Darian calendar for Mars is a mechanism by which Martian solar days
(also known as "sols") can be labelled in a manner useful to inhabitants
of Mars.  This module provides functions to convert dates between the
Darian calendar and Chronological Mars Solar Day Numbers, which is a
suitable format to do arithmetic with.  It also supplies functions that
describe the shape of the Darian calendar, to assist in calendrical
calculations.  It also supplies functions to represent Darian dates
textually in a conventional format.
The Darian calendar divides time up into years, months, and days.
This module also supports dividing the Darian year directly into days,
with no months.
The Chronological Mars Solar Day Number is an integral number labelling
each Martian day, where the day extends from midnight to midnight in
whatever time zone is of interest.  It is a linear count of days, where
each day's number is one greater than the previous day's number.
This module places no limit on the range of dates to which it may be
applied.  All function arguments are permitted to be "Math::BigInt" or
lib/Date/Darian/Mars.pm view on Meta::CPAN
=head1 NAME
Date::Darian::Mars - the Darian calendar for Mars
=head1 SYNOPSIS
    use Date::Darian::Mars qw(present_y);
    print present_y($y);
    use Date::Darian::Mars qw(
	month_days cmsdn_to_ymd ymd_to_cmsdn present_ymd);
lib/Date/Darian/Mars.pm view on Meta::CPAN
	year_days cmsdn_to_yd yd_to_cmsdn present_yd);
    $yd = year_days(209);
    ($y, $d) = cmsdn_to_yd(546236);
    $cmsdn = yd_to_cmsdn(209, 631);
    print present_yd(546236);
    print present_yd(209, 631);
=head1 DESCRIPTION
The Darian calendar for Mars is a mechanism by which Martian solar days
(also known as "sols") can be labelled in a manner useful to inhabitants
of Mars.  This module provides functions to convert dates between the
Darian calendar and Chronological Mars Solar Day Numbers, which is a
suitable format to do arithmetic with.  It also supplies functions that
describe the shape of the Darian calendar, to assist in calendrical
calculations.  It also supplies functions to represent Darian dates
textually in a conventional format.
The Darian calendar divides time up into years, months, and days.
This module also supports dividing the Darian year directly into days,
with no months.
The Chronological Mars Solar Day Number is an integral number labelling
each Martian day, where the day extends from midnight to midnight in
whatever time zone is of interest.  It is a linear count of days, where
each day's number is one greater than the previous day's number.
This module places no limit on the range of dates to which it may be
applied.  All function arguments are permitted to be C<Math::BigInt> or
C<Math::BigRat> objects in order to achieve arbitrary range.  Native Perl
integers are also permitted, as a convenience when the range of dates
being handled is known to be sufficiently small.
=head1 DARIAN CALENDAR FOR MARS
The main cycle in the Darian calendar is the year.  It approximates the
length of a Martian tropical year (specifically, the northward equinoctal
year), and the year starts approximately on the northward equinox.
Years are either 668 or 669 Martian solar days long.  669-day years are
referred to as "leap years".
Each year is divided into 24 months, of nearly equal length.  The months
are purely nominal: they do not correspond to any astronomical cycle.
Each quarter of the year consists of five months of 28 days followed by
one month of 27 days, except that the last month of a leap year contains
28 days instead of 27.
lib/Date/Darian/Mars.pm view on Meta::CPAN
Days within each month are numbered sequentially, starting at 1.
The months have names (in fact several competing sets of names), but this
module does not deal with the names.  In this module, months within each
year are numbered sequentially from 1.
Years are numbered sequentially.  Year 0 is the year in which the first
known telescopic observations of Mars occurred.  Specifically, year 0
started at the midnight that occurred on the Airy meridian (the Martian
prime meridian) at approximately MJD -91195.22 in Terrestrial Time.
The calendar is described canonically, and in more detail, at
L<http://pweb.jps.net/~tgangale/mars/converter/calendar_clock.htm>.
The day when Mars Exploration Rover "Opportunity" landed in Meridiani
Planum was 0209-23-18 or 0209-631 in the Darian calendar, and CMSDN
546236.
=cut
package Date::Darian::Mars;
{ use 5.006; }
use warnings;
use strict;
lib/Date/Darian/Mars.pm view on Meta::CPAN
	my($y) = @_;
	my($sign, $digits) = ("$y" =~ /\A\+?(-?)0*([0-9]+?)\z/);
	$digits = ("0" x (4 - length($digits))).$digits
		unless length($digits) >= 4;
	$sign = "+" if $sign eq "" && length($digits) > 4;
	return $sign.$digits;
}
=back
=head2 Darian calendar
Each year is divided into 24 months, numbered [1, 24].  Each month is
divided into days, numbered sequentially from 1.  The month lengths
are irregular.  The year numbers have unlimited range.
=over
=item month_days(YEAR, MONTH)
The parameters identify a month, and the function returns the number of
lib/Date/Darian/Mars.pm view on Meta::CPAN
	return sprintf("%s-%02d-%02d", present_y($y),
		_numify($m), _numify($d));
}
=back
=head2 Ordinal dates
Each year is divided into days, numbered sequentially from 1.  The year
lengths are irregular.  The years correspond exactly to those of the
Darian calendar.
=over
=item year_days(YEAR)
The parameter identifies a year, and the function returns the number of
days in that year as a native Perl integer.
=cut
lib/Date/Darian/Mars.pm view on Meta::CPAN
			unless $d >= 0 && $d < 1000;
	}
	return sprintf("%s-%03d", present_y($y), _numify($d));
}
=back
=head1 SEE ALSO
L<Date::MSD>,
L<http://pweb.jps.net/~tgangale/mars/converter/calendar_clock.htm>,
L<http://www.fysh.org/~zefram/time/define_cmsd.txt>
=head1 AUTHOR
Andrew Main (Zefram) <zefram@fysh.org>
=head1 COPYRIGHT
Copyright (C) 2007, 2009, 2011, 2017
Andrew Main (Zefram) <zefram@fysh.org>
( run in 0.532 second using v1.01-cache-2.11-cpan-5dc5da66d9d )