DateTime-Calendar-Julian
    
    
  
  
  
view release on metacpan or search on metacpan
0.107		2022-01-30	T. R. Wyant
    Add method calendar_name(), which returns 'Julian'.
    Require DateTime 1.48 for is_last_day_of_quarter().  This is a
    significant bump, since the previous was 0.08.
    Update Perl requirement in metadata to 5.008004.  It was always this
    in fact, since DateTime requires this, as does Makefile.PL.
    Add support for quarters.
0.106		2021-09-25	T. R. Wyant
{
   "abstract" : "DateTime object in the Julian calendar",
   "author" : [
      "Eugene van der Pijll <pijll@gmx.net>",
      "Thomas R. Wyant, III <wyant at cpan dot org>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
---
abstract: 'DateTime object in the Julian calendar'
author:
  - 'Eugene van der Pijll <pijll@gmx.net>'
  - 'Thomas R. Wyant, III <wyant at cpan dot org>'
build_requires:
  Test::More: '0.88'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010'
license: perl
Makefile.PL view on Meta::CPAN
my %args = (
    NAME		=> 'DateTime::Calendar::Julian',
    VERSION_FROM	=> 'lib/DateTime/Calendar/Julian.pm',
    PREREQ_PM		=> {
	DateTime	=> 1.48,	# For is_last_day_of_{quarter,year}
	strict		=> 0,
	vars		=> 0,
	warnings	=> 0,
    },
    ABSTRACT		=> 'DateTime object in the Julian calendar',
    AUTHOR		=> [
	'Eugene van der Pijll <pijll@gmx.net>',
	'Thomas R. Wyant, III <wyant at cpan dot org>',
    ],
    PL_FILES => {},	# Prevent old MakeMaker from running Build.PL
    realclean	=> {
	FILES	=> 'cover_db',
    },
);
DateTime/Calendar/Julian
========================
This is a companion module to DateTime.pm. It implements the Julian
calendar. It supports everything that DateTime.pm supports and more:
about one day per century more, to be precise.
INSTALLATION
To install this module type the following:
   perl Makefile.PL
   make
   make test
   make install
lib/DateTime/Calendar/Julian.pm view on Meta::CPAN
    } else {
        return $ix - 1;
    }
}
my @start_of_month = (0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337);
# Julian dates are formatted in exactly the same way as Gregorian dates,
# so we use most of the DateTime methods.
# This is the difference between Julian and Gregorian calendar:
sub _is_leap_year {
    my (undef, $year) = @_;	# Invocant unused
    return ($year % 4 == 0);
}
# Algorithms from http://home.capecod.net/~pbaum/date/date0.htm
sub _ymd2rd {	## no critic (ProhibitUnusedPrivateSubroutines)
    my (undef, $y, $m, $d) = @_;	# Invocant unused
lib/DateTime/Calendar/Julian.pm view on Meta::CPAN
	    my $doq = $doy - ( $class->_is_leap_year( $y ) ?
		$LeapYearQuarterStart[ $quarter - 1 ] :
		$QuarterStart[ $quarter - 1 ] );
	    return $y, $m, $d, $dow, $doy, $quarter, $doq;
	}
	return $y, $m, $d;
    }
}
sub calendar_name {
    return 'Julian';
}
sub epoch {
    my $self = shift;
    my $greg = DateTime->from_object( object => $self );
    return $greg->epoch;
}
lib/DateTime/Calendar/Julian.pm view on Meta::CPAN
    $sep = 'J' unless defined $sep;
    return join $sep, $self->ymd( '-' ), $self->hms( ':' );
}
1;
__END__
=head1 NAME
DateTime::Calendar::Julian - Dates in the Julian calendar
=head1 SYNOPSIS
  use DateTime::Calendar::Julian;
  $dt = DateTime::Calendar::Julian->new( year  => 964,
                                         month => 10,
                                         day   => 16,
                                       );
lib/DateTime/Calendar/Julian.pm view on Meta::CPAN
implements all methods of DateTime; see the DateTime(3) manpage for all
methods.
=head1 METHODS
This module implements one additional method besides the ones from
DateTime, and changes the output of one other method.
=over 4
=item * calendar_name
Returns C<'Julian'>.
=item * gregorian_deviation
Returns the difference in days between the Gregorian and the Julian
calendar.
=item * datetime
  print $dt->datetime( $sep ), "\n";
This method is equivalent to
  join $sep, $dt->ymd( '-' ), $dt->hms( ':' );
The C<$sep> argument defaults to C<'J'>.
lib/DateTime/Calendar/Julian.pm view on Meta::CPAN
C<'J'>, depending on which version of L<DateTime|DateTime> was
installed.
=back
B<Note> that as of version C<0.106_01>, methods related to quarters
should work.
=head1 BACKGROUND
The Julian calendar was introduced by Julius Caesar in 46BC.  It
featured a twelve-month year of 365 days, with a leap year in February
every fourth year.  This calendar was adopted by the Christian church in
325AD.  Around 532AD, Dionysius Exiguus moved the starting point of the
Julian calendar to the calculated moment of birth of Jesus Christ. Apart
from differing opinions about the start of the year (often January 1st,
but also Christmas, Easter, March 25th and other dates), this calendar
remained unchanged until the calendar reform of pope Gregory XIII in
1582.  Some backward countries, however, used the Julian calendar until
the 18th century or later.
This module uses the proleptic Julian calendar for years before 532AD,
or even 46BC.  This means that dates are calculated as if this calendar
had existed unchanged from the beginning of time.  The assumption is
made that January 1st is the first day of the year.
Note that BC years are given as negative numbers, with 0 denoting the
year 1BC (there was no year 0AD!), -1 the year 2BC, etc.
=head1 SUPPORT
Support for this module is provided via the F<datetime@perl.org> email
list. See L<https://lists.perl.org/> for more details.
    skip 'epoch not UNIX', 2 unless gmtime(0) eq 'Thu Jan  1 00:00:00 1970';
    $d = DateTime::Calendar::Julian->from_epoch( epoch => 0 );
    is( $d->epoch, 0, 'epoch 0' );
    is( $d->ymd, '1969-12-19', 'epoch is correct' );
}
$d = DateTime::Calendar::Julian->new( year => 1900, month => 10, day => 1, time_zone => 'floating');
$d->add( years => 1 );
is($d->ymd, '1901-10-01', 'adding a year');
is( $d->calendar_name, 'Julian', 'Calendar name' );
( run in 0.787 second using v1.01-cache-2.11-cpan-5dc5da66d9d )