Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
DateTime::Calendar::MaUser3Contributed Perl DocumeDateTime::Calendar::Mayan(3)

       DateTime::Calendar::Mayan - The Mayan Long Count, Haab, and Tzolkin

	  use DateTime::Calendar::Mayan

	  my $dtcm = DateTime::Calendar::Mayan->new(
	       baktun  => 12,
	       katun   => 19,
	       tun     => 10,
	       uinal   => 2,
	       kin     => 8,
	       # alternate epoch
	       epoch   => DateTime->new(
		       year    => -3113,
		       month   => 8,
		       day     => 13,

	  print	$dtcm->date;
	  # prints
	  print	$dtcm->haab;
	  # prints 3 Uayeb
	  print	$dtcm->tzolkin;
	  # prints 3 Oc

       An implementation of the	Mayan Long Count, Haab,	and Tzolkin calendars
       as defined in "Calendrical Calculations The Millennium Edition".
       Supplemented by "Frequently Asked Questions about Calendars".

       o   new(	baktun => $scalar, ...,	epoch => $object )

	   Accepts a hash representing a date on the Long Count	calendar and a
	   "DateTime::Calendar"	object specifying an alternate epoch.  All
	   keys	are optional.

	      The units	are:
	      kin   = 1	day
	      uinal = 20 days
	      tun   = 360 days
	      katun = 7200 days
	      baktun = 144000 days

	   In the future pictuns, calabtuns, kinchiltuns, and alautuns may be

       o   now

	   Alternate constructor.  Uses	DateTime->now to set the current date.

       o   today

	   Alternate constructor.  Uses	DateTime->today	to set the current

       o   clone

	   This	object method returns a	replica	of the given object.

       o   from_object(	object => $object )

	   Accepts a "DateTime::Calendar" object.  Although this calendar
	   doesn't support time	it will	preserve the time value	of objects
	   passed to it.  This prevents	a loss of precision when chaining

	   Note: Language support is not implemented.

       o   utc_rd_values

	   Returns the current UTC Rata	Die days, UTC Rata Die seconds,	and
	   nanoseconds as a three element list.

       o   from_epoch( epoch =>	$scalar	)

	   Creates a new object	from a number of seconds relative to midnight

       o   epoch

	   Returns the number of seconds since midnight	1970-01-01.

       o   set_mayan_epoch( object => $object )

	   Accepts a "DateTime::Calendar" object.  The epoch is	set to this
	   value on a per object basis

	   The default epoch is:

	      Aug. 11, -3113 / Sep. 6, 3114 B.C.E. / 584,283 JD

       o   mayan_epoch

	   Returns a "DateTime::Calendar::Mayan" object	set to the current
	   Mayan epoch.

       o   date

       o   bktuk

       o   long_count( $scalar )

	   Returns the Long Count calendar date.  Think	DateTime::ymd.	Like
	   ymd this method also	accepts	an optional field separator string.

       o   haab( $scalar )

	   Returns the Haab calendar date.  Accepts an optional	field
	   separator string.

       o   tzolkin( $scalar )

	   Returns the Tzolkin calendar	date.  Accepts an optional field
	   separator string.

       o   baktun

       o   katun

       o   tun

       o   uinal

       o   kin(	$scalar	)

	   Gets/Sets the long count value of the function name.

       o   set_baktun

       o   set_katun

       o   set_tun

       o   set_uinal

       o   set_kin( $scalar )

	   Aliases to the combined accessor/mutators.

       o   set(	baktun => $scalar, ... )

	   Accepts a hash specifying new long count values.  All units are

       o   add

       o   subtract( baktun => $scalar,	... )

	   Accepts a hash specifying values to add or subject from the long
	   count.  All units are optional.

       o   add_duration

       o   subtract_duration( $object )

	   Accepts a "DateTime::Duration" object and either adds or subtracts
	   it from the current date.   See the DateTime::Duration docs for
	   more	details.

       Please see:

       Chapter 10 of Calendarical Calculations "The Millennium Edition".


       Chapter 7 of Frequently Asked Questions about Calendars.

       The Long	Count calendar is cyclical and it is possible to have
       different dates in other	calendars that convert to be the same Long
       Count date.  Under this calendar	the dates and are

       The Long	Count calendar will next roll over in late 2012	(Gregorian).
       In anticipation of this Long Count dates	input as 0-12.*.*.*.* will
       convert to Gregorian dates in the Mayan year that started in -3113
       (Gregorian).  Long Count	dates input as 13.*.*.*.* will convert to
       Gregorian dates in the Mayan year that start in 2012 (Gregorian).


	  use DateTime;
	  use DateTime::Calendar::Mayan;

	  my $dtcm = DateTime::Calendar::Mayan->new( baktun => 0 );
	  print	$dtcm->date, "\n";
	  print	DateTime->from_object( object => $dtcm )->ymd, "\n";

	  $dtcm->set( baktun =>	13);
	  print	$dtcm->date, "\n";
	  print	DateTime->from_object( object => $dtcm )->ymd, "\n";

       Will print:

       As you can see the Long Count dates are identical but the Gregorian
       equivalent dates	are different.

       Support for a count of Mayan "years" or "cycles"	allowing accurate
       conversion to/from Gregorian dates may be added to this module in the
       future.	This would be an extension to the historical Long Count

       Dave Rolsky (DROLSKY) for the DateTime project and carrying us this

       Eugene van der Pijll (PIJLL) for	DateTime::Calendar::Julian which I
       looked at more then once.

       Calendrical Calculations	"The Millennium	Edition" By Edward M. Reingold
       & Nachum	Dershowitz.  (ISBN 0-521-77752-6 paperback)

       Abigail (ABIGAIL) for Date::Maya	from which I confirmed the algorithm
       for Mayan years.

       "Frequently Asked Questions about Calendars" by Claus Tondering.

       Support for this	module is provided via the email
       list. See	for more details.

       Joshua Hoblitt <>

       Copyright (c) 2003 Joshua Hoblitt.  All rights reserved.	 This program
       is free software; you can redistribute it and/or	modify it under	the
       same terms as Perl itself.

       The full	text of	the license can	be found in the	LICENSE	file included
       with this module.

SEE ALSO mailing list

perl v5.32.1			  2021-03-01	  DateTime::Calendar::Mayan(3)


Want to link to this manual page? Use this URL:

home | help