DateTime-Calendar-Discordian

 view release on metacpan or  search on metacpan

lib/DateTime/Calendar/Discordian.pm  view on Meta::CPAN


=head1 NAME

DateTime::Calendar::Discordian - Perl extension for the Discordian Calendar

=head1 SYNOPSIS

  use DateTime::Calendar::Discordian;

=head1 ABSTRACT

A module that implements the Discordian calendar made popular(?) in the
"Illuminatus!" trilogy by Robert Shea and Robert Anton Wilson and by the
Church of the SubGenius.

=cut

package DateTime::Calendar::Discordian;

use strict;
use warnings;
use 5.010;
use Carp;
use DateTime::Locale;
use Params::Validate qw( validate SCALAR OBJECT UNDEF);

=head1 VERSION

This document describes DateTime::Calendar::Discordian version 1.0

=cut

our $VERSION = '1.0';

=head1 DESCRIPTION

=head2 The Discordian Calendar

=head3 Seasons 

	Name            Patron apostle
	----            --------------
	Chaos           Hung Mung
	Discord         Dr. Van Van Mojo
	Confusion       Sri Syadasti
	Bureaucracy	    Zarathud
	The Aftermath   The Elder Malaclypse

Each season contains 73 consecutively numbered days.

=head3 Holydays

	Apostle Holydays    Season Holydays
	----------------    ---------------
	1) Mungday          1) Chaoflux
	2) Mojoday          2) Discoflux
	3) Syaday           3) Confuflux
	4) Zaraday          4) Bureflux
	5) Maladay          5) Afflux

Apostle Holydays occur on the 5th day of the season.

Season Holydays occur on the 50th day of the deason.

St. Tib's Day occurs once every 4 years (1+4=5) and is inserted between
the 59th and 60th days of the Season of Chaos. 

The era of the Discordian Calendar is called Year Of Lady Discord
(YOLD.) Its' epoch (Confusion 1 of year 0) is equivalent to January 1,
-1167 B.C.

X Day is when the Church of the SubGenius believes the alien X-ists will

lib/DateTime/Calendar/Discordian.pm  view on Meta::CPAN

}

sub _rd2discordian {
    my ( $self, $rd ) = @_;

    my $n400 = _floor( $rd / 146_097 );
    my $d1   = $rd % 146_097;
    my $n100 = _floor( $d1 / 36_524 );
    my $d2   = $d1 % 36_524;
    my $n4   = _floor( $d2 / 1461 );
    my $d3   = $d2 % 1461;
    my $n1   = _floor( $d3 / 365 );
    my $d4   = $d3 % 365;

    # $d4 == 0 is the last day of the year so has to be special cased.
    my $year =
      ( 400 * $n400 ) +
      ( 100 * $n100 ) +
      ( 4 * $n4 ) +
      $n1 + 1166 +
      ( ( $d4 == 0 ) ? 0 : 1 );

    my ( $season, $day );
    if ( $d4 == 60 && _is_leap_year( $year - 1166 ) ) {
        $season = undef;
        $day    = q{St. Tib's Day};
    }
    else {
        my @seas =
          ( 'Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath', );
        $season = ( $d4 == 0 ) ? $seas[4] : $seas[ _floor( $d4 / 73 ) ];

        $day = ( $d4 == 0 ) ? 73 : $d4 - $seasons{$season}->{offset};

        if ( $d4 > 60 && _is_leap_year( $year - 1166 ) ) {
            $day--;
        }

        if ( $day < 1 ) {
            $day += 73;
        }
    }

    return ( $day, $season, $year );
}

1;
__END__

=head1 SUPPORT

After installing, you can find documentation for this module with the perldoc
command.

    perldoc DateTime::Calendar::Discordian

Support for this module is provided via the datetime@perl.org email list. See
L<lists.perl.org|http://lists.perl.org/> for more details.

Please submit bugs to the L<CPAN RT system|http://rt.cpan.org/NoAuth/ReportBug.html?Queue=datetime-Calendar-Discordian>
or via email at bug-datetime-calendar-discordian@rt.cpan.org.

You can also look for information at:

=over 4

=item * L<Search CPAN.|http://search.cpan.org/dist/DateTime-Calendar-Discordian>

=item * L<AnnoCPAN, annotated CPAN documentation.|http://annocpan.org/dist/DateTime-Calendar-Discordian>

=item * L<CPAN Ratings.|http://cpanratings.perl.org/d/DateTime-Calendar-Discordian>

=back

=head1 AUTHOR

Jaldhar H. Vyas, E<lt>jaldhar@braincells.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2012, Consolidated Braincells Inc.

This distribution is free software; you can redistribute it and/or modify it
under the terms of either:

a) the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version, or

b) the Artistic License version 2.0.

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

=head1 SEE ALSO

=over 4

=item * L<The DateTime project web site.|http://datetime.perl.org/>

=item * L<The Principia Discordia.|http://www.ology.org/principia/>

=item * L<The Church of the SubGenius.|http://www.subgenius.com/>

=back

=cut



( run in 0.769 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )