view release on metacpan or search on metacpan
      Module::Metadata can be loaded.
0.06		2016-11-20	T. R. Wyant
    - Repackage licenses into LICENSE/ directory
    - Implement full DateTime interface. Unless I missed something.
    - Better validation on reform dates (I hope!), plus more ways to
      specify.
    - Add method calendar_name, and override strftime() so that
      calendar_name() can appear in a template.
    - Add author tests for various desiderata,
0.05		2016-11-08	T. R. Wyant
    - Convert from DateTime language interface to DateTime locale
      interface.
    - Require Perl 5.008004, since DateTime does.
    - Add today() constructor, with same caveats as truncate().
    - Add Tom Wyant to author and copyright notices.
    - Use warnings.
0.04  2003-07-28	Eugene van der Pijll
    - DateTime 0.14 introduced some incompatible changes.
      Updated DT::C::Christian to this new DateTime version.
    - If new() is passed a date which is one of the missing days (during
      a calendar transform), this is now interpreted as a proleptic
      Gregorian date; this means that the returned date is now *before*
      the calendar change, instead of *after* the change.
0.03  2003-04-24	Eugene van der Pijll
    - added nanosecond support, by requiring DateTime 0.10
    - a change in DateTime caused a failure of a test script (t/08math.t
      again); fortunately it was in a TODO block; replaced that by
      todo_skip
0.02  2003-03-27	Eugene van der Pijll
    - how embarrassing - there's a bug in t/08math.t ... now fixed, of
      course
    - added a number of calendar reform dates; there are now 41 of them
      included
0.01  2003-03-26	Eugene van der Pijll
	- original version (still buggy, probably)
Changes
eg/README
eg/which-calendar
lib/DateTime/Calendar/Christian.pm
LICENSES/Artistic
LICENSES/Copying
LICENSES/README
Makefile.PL
MANIFEST
META.json
META.yml
README
t/01load.t
{
   "abstract" : "Dates in the Christian (combined Julian/Gregorian) calendar",
   "author" : [
      "Eugene van der Pijll <pijll@gmx.net>",
      "Thomas R. Wyant, III <wyant at cpan dot org>",
      "realclean",
      {
         "FILES" : "cover_db"
      }
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010",
---
abstract: 'Dates in the Christian (combined Julian/Gregorian) calendar'
author:
  - 'Eugene van der Pijll <pijll@gmx.net>'
  - 'Thomas R. Wyant, III <wyant at cpan dot org>'
  - realclean
  -
    FILES: cover_db
build_requires:
  Storable: '0'
  Test::More: '0.88'
configure_requires:
Makefile.PL view on Meta::CPAN
    PL_FILES => {},	# Prevent old MakeMaker from running Build.PL
    PREREQ_PM		=> {
			    'Carp'	=> 0,
			    'DateTime' => 1.53,	# rfc3339
			    'DateTime::Calendar::Julian' => 0.107,
			    constant	=> 0,
			    overload	=> 0,
			    strict	=> 0,
			    warnings	=> 0,
                       },
    ABSTRACT        => 'Dates in the Christian (combined Julian/Gregorian) calendar',
    AUTHOR          => [
	'Eugene van der Pijll <pijll@gmx.net>',
	'Thomas R. Wyant, III <wyant at cpan dot org>',
    realclean	=> { FILES => 'cover_db' },
    ],
);
$mmv >= 6.31
    and $args{LICENSE} = 'perl';
DateTime-Calendar-Christian
===========================
This module implements the Christian calendar, which consists of both
the Julian and the Gregorian calendars.
INSTALLATION
To install this module type the following:
   perl Makefile.PL
   make
   make test
   make install
This directory contains examples of using DateTime::Calendar::Christian.
Specifically:
README
    This file.
which-calendar
    Given an ISO-8601-ish date on the command line, this Perl script
    displays which calendar is appropriate. A command option specifies
    the reform date. If desired, another command option will get you
    output from other methods than the default calendar_name(). The
    --help option gets you the POD for the script.
# ex: set filetype=text textwidth=72 autoindent :
eg/which-calendar view on Meta::CPAN
use strict;
use warnings;
use DateTime::Calendar::Christian;
use Getopt::Long 2.33 qw{ :config auto_version };
use Pod::Usage;
our $VERSION = '0.14';
my %opt = (
    method	=> 'calendar_name',
);
GetOptions( \%opt,
    qw{ method=s reform_date|reform-date=s },
    help => sub { pod2usage( { -verbose => 2 } ) },
)
    and @ARGV
    and DateTime::Calendar::Christian->can( $opt{method} )
    or pod2usage( { -verbose => 0 } );
eg/which-calendar view on Meta::CPAN
    @arg{ @names[0 .. $#values ] } = @values;
    my $dt = DateTime::Calendar::Christian->new( %arg );
    local $\ = "\n";
    print join ' ', $date, $dt->$method();
}
__END__
=head1 TITLE
which-calendar - Figure out which calendar a date is in
=head1 SYNOPSIS
 which-calendar 1732-2-11
 which-calendar -reform-date uk 1732-2-11
 which-calendar -help
 which-calendar -version
=head1 OPTIONS
=head2 -help
This option displays the documentation for this script. The script then
exits.
=head2 -method
 -method ymd
This option specifies the method to call to generate results. The
default is C<'calendar_name'>.
=head2 -reform-date
 -reform-date uk
This option specifies a reform date to use for the determination. The
default is the default for
L<DateTime::Calendar::Christian|DateTime::Calendar::Christian>, which is
C<'italy'>.
=head2 -version
This option displays the version of this script. The script then exits.
=head1 DETAILS
This Perl script takes as command arguments one or more ISO-8601-ish
dates, and displays each date and the calendar the date is in
(C<'Gregorian'> or C<'Julian'>).
The date is a string containing year, month, day, hour, minute and
second, punctuated by non-numeric characters. Only the year is required.
The calendar name is obtained by instantiating a
L<DateTime::Calendar::Christian|DateTime::Calendar::Christian> object
with each specified date, and then calling its C<calendar_name()>
method. The logic actually works with any method that takes no arguments
and returns a string, so the L<-method|/-method> option is provided for
those who want to play around with the functionality.
=head1 AUTHOR
Thomas R. Wyant, III (F<wyant at cpan dot org>)
=head1 COPYRIGHT AND LICENSE
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
	    if ( my $rda = $reform_dates{ my $rd_lc = lc $rd } ) {
		ARRAY_REF eq ref $rda
		    and return ( $reform_dates{$rd_lc} =
		    $class->_process_reform_date( $rda ) );
		return $rda;
	    }
	    if ( $rd =~ m/ \A [0-9] /smx
		    and my @rda = split qr{ [^0-9]+ }smx, $rd ) {
		return $class->_process_reform_date( \@rda );
	    }
	    Carp::croak( "Unknown calendar region '$rd'" );
	} elsif ( ref $class && ( ref $class )->can( 'reform_date' ) ) {
	    return $class->reform_date();
	} else {
	    return $class->DefaultReformDate();
	}
    }
}
__PACKAGE__->DefaultReformDate( 'Italy' );
sub new {
    my ( $class, %args ) = @_;
    my $self = $class->_new( \%args );
    if (defined $args{year}) {
        $self->{date} = DateTime::Calendar::Julian->new(%args);
        if ($self->{date} >= $self->{reform_date}) {
            $self->{date} = DateTime->new(%args);
            $self->_adjust_calendar;
        }
    }
    return $self;
}
sub _new {
    my ( $class, $arg, $method ) = @_;
    my $self = bless {
	reform_date	=> $class->_process_reform_date(
	    delete $arg->{reform_date} ),
    }, ref $class || $class;
    if ( $method ) {
	$self->{date} = DateTime->$method( %{ $arg } );
	$self->_adjust_calendar();
    }
    return $self;
}
sub _adjust_calendar {
    my $self = shift;
    if ($self->is_gregorian and $self->{date} < $self->{reform_date}) {
        $self->{date} = DateTime::Calendar::Julian->from_object(
                                                object => $self->{date} );
    } elsif ($self->is_julian and $self->{date} >= $self->{reform_date}) {
        $self->{date} = DateTime->from_object( object => $self->{date} );
    }
    return;
}
sub is_julian {
    return $_[0]{date}->isa('DateTime::Calendar::Julian');
}
sub is_gregorian {
    return ! $_[0]->is_julian;
}
sub calendar_name {
    my ( $self ) = @_;
    return $self->is_julian() ? 'Julian' : 'Gregorian';
}
sub from_epoch {
    my ( $class, %args ) = @_;
    return $class->_new( \%args, 'from_epoch' );
}
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
    $p{day} = 1;
    $p{month}++;
    if ($p{month} > 12) {
        $p{month} -= 12;
        $p{year}++;
    }
    my $self = $class->new( %p );
    if ($self->month != $p{month}) {
        # Apparently, month N+1 does not have a day 1.
        # This means that this date is removed in the calendar reform,
        # and the last day of month N is the last day before the reform.
        $self = $self->from_object( object => $self->{reform_date} );
    }
    # Subtract one. That should be the last day of the month.
    $self->subtract( days => 1 );
    return $self;
}
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
sub is_leap_year {
    my $self = shift;
    my $year = $self->year;
    # This could go wrong if the number of missing days is more than
    # about 300, and reform_date lies at the beginning of the next year.
    if ($year != $self->{reform_date}->year) {
        return $self->{date}->is_leap_year;
    }
    # Difficult case: $year is in the year of the calendar reform
    # Test if Feb 29 exists
    my $d = eval { $self->new( year  => $year,
                               month => 2,
                               day   => 29,
                             ) };
    return defined($d) && $d->month == 2 && $d->day == 29;
}
sub _add_overload {
    my ($dt, $dur, $reversed) = @_;
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
    my $self = shift;
    my $dt = shift;
    return $self->{date} - $dt->{date};
}
sub add_duration {
    my ($self, $dur) = @_;
    # According to the papal bull and the English royal decree that
    # introduced the Gregorian calendar, dates should be calculated as
    # if the change did not happen; this makes date math very easy in
    # most cases...
    # But not all.
    my %deltas = $dur->deltas;
    # We take the components of DateTime::Duration in the same order
    # that DateTime itself does.
    if ( my $days = delete $deltas{days} ) {
	# Days must not be adjusted further, for sanity's sake. See RT
	# 140734.
	$self->{date}->add( days => $days );
	$self->_adjust_calendar;
    }
    if ( my $months = delete $deltas{months} ) {
	# This must be adjusted to avoid regression.
	# TODO there are other sane things to do here.
	my $start_jul = $self->is_julian;
	$self->{date}->add( months => $months);
	$self->_adjust_calendar;
	# The intent of the following code is to implement the usual
	# conversion, by adding or subtracting the Gregorian deviation
	# as of the reform date. An example would be that George
	# Washington was born on February 11 1732 Julian. The reform
	# took this to February 22 Gregorian, and that is the date
	# usually given, even though a couple more days' difference has
	# accumulated since then.
	#
	# A straightforward implementation would be to do the change in
	# two steps: addition would be in Julian to the reform date and
	# then in Gregorian for the rest of the interval, and vice versa
	# for subtraction. But that would involve going back and redoing
	# tha calculation.
	#
	# What this implementation does is to recognize that part of the
	# calculation has been done in the wrong calendar, and correct
	# for the number of leap year days that did (or did not) occur
	# under the correct calendar.
	#
	# The original implementation nade this correction in all cases.
	# But as Christian Carey found out, this gives incorrect (or at
	# least very surprising) results when adding or subtracting
	# enough days to not only cross the reform date but cross one of
	# the years affected by the reform. His example was that adding
	# 43,099 days to 1583-03-01 (Julian) correctly gave 1700-03-11
	# (Gregorian), but adding 43,100 days also gave 1700-03-11
	# rather than 1700-03-12. This is described (sketchily) in RT
	# 140734.
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
	    $dd = $self->gregorian_deviation($self->{reform_date}) -
		  $self->gregorian_deviation($self->{date});
	}
	$self->{date}->subtract( days => $dd ) if $dd;
    }
    if ( keys %deltas ) {
	$self->{date}->add( %deltas );
	$self->_adjust_calendar;
    }
    return $self;
}
sub gregorian_deviation {
    my ($class, $date) = @_;
    $date ||= $class;
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
    my $new_dt = (ref $self)->new( %old_p, %p );
    %$self = %$new_dt;
    return $self;
}
sub set_time_zone {
    my ( $self, @arg ) = @_;
    $self->{date}->set_time_zone( @arg );
    $self->_adjust_calendar;
    return $self;
}
# This code assumes there is a month of December of the previous year.
sub day_of_year {
    my $self = shift;
    my $doy = $self->{date}->doy;
    if ($self->year == $self->reform_date->year &&
        $self >= $self->reform_date ) {
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
    return $doy;
}
sub day_of_year_0 {
    return shift->day_of_year - 1;
}
sub strftime {
    my ( $self, @fmts ) = @_;
    foreach ( @fmts ) {
	s/ %\{ ( calendar_name ) \} / $self->_strftime_helper( "$1" ) /smxge;
    }
    return $self->{date}->strftime( @fmts );
}
sub _strftime_helper {
    my ( $self, $method ) = @_;
    my $rslt = $self->$method();
    $rslt =~ s/ % /%%/smxg;
    return $rslt;
}
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
	    and $DefaultReformDate = $class->_process_reform_date( $rd );
	return $DefaultReformDate;
    }
}
1;
__END__
=head1 NAME
DateTime::Calendar::Christian - Dates in the Christian calendar
=head1 SYNOPSIS
  use DateTime::Calendar::Christian;
  $dt = DateTime::Calendar::Christian->new( year  => 1752,
                                            month => 10,
                                            day   => 4,
                                            reform_date => $datetime );
=head1 DESCRIPTION
DateTime::Calendar::Christian is the implementation of the combined
Julian and Gregorian calendar.
See L<DateTime> for information about most of the methods.
=head1 BACKGROUND
The Julian calendar, introduced in Roman times, had an average year
length of 365.25 days, about 0.03 days more than the correct number. When
this difference had accumulated to about ten days, the calendar was
reformed by pope Gregory XIII, who introduced a new leap year rule. To
correct for the error that had built up over the centuries, ten days
were skipped in October 1582. In most countries, the change date was
later than that; England went Gregorian in 1752, and Russia didn't
change over until 1918.
=head1 METHODS
This manpage only describes those methods that differ from those of
DateTime. See L<DateTime|DateTime> for all other methods. A spirited
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
Besides the usual parameters ("year", "month", "day", "hour", "minute",
"second", "nanosecond", "locale", "formatter" and "time_zone"),
this class method takes the additional "reform_date" parameter. See
L<SPECIFYING REFORM DATE|/SPECIFYING REFORM DATE> below for how to
specify this.
If this method is used as an instance method and no "reform_date" is
given, the "reform_date" of the returned object is the same as the one
of the object used to call this constructor. This means you can make
"date generators", that implement a calendar with a fixed reform date:
  $english_calendar = DateTime::Calendar::Christian(
                          reform_date => DateTime->new( year  => 1752,
                                                        month => 9,
                                                        day   => 14 )
                                                   );
or equivalently:
  $english_calendar = DateTime::Calendar::Christian(
                          reform_date => 'UK' );
You can use this generator to create dates with the given reform_date:
  $born = $english_calendar->new( year => 1732, month => 2, day => 22 );
  $died = $english_calendar->new( year => 1799, month => 12, day => 14 );
When a date is given that was skipped during a calendar reform, it is
assumed that it is a Gregorian date, which is then converted to the
corresponding Julian date. This behaviour may change in future
versions. If a date is given that can be both Julian and Gregorian, it
will be considered Julian. This is a bug.
=item * from_epoch, from_object, from_day_of_year, last_day_of_month
These methods accept an additional "reform_date" argument. Note that the
epoch is defined for most (all?) systems as a date in the Gregorian
calendar. B<But> this module will still represent it as a Julian date if
the epoch gives a date before the reform date.
=item * reform_date
Returns the date of the calendar reform, as a DateTime object.
=item * is_julian, is_gregorian
Return true or false indicating whether the datetime object is in a
specific calendar.
=item * calendar_name
Return C<'Julian'> or C<'Gregorian'>, depending on the value returned by
C<is_julian()>.
=item * is_leap_year
This method returns a true or false indicating whether or not the
datetime object is in a leap year. If the object is in the year of the
date reform, this method indicates whether there is a leap day in that
year, irrespective of whether the datetime object is in the same
calendar as the possible leap day.
=item * days_in_year
Returns the number of days in the year. Is equal to 365 or 366, except
for the year(s) of the calendar reform.
=item * day_of_year, day_of_year_0
Returns the day of the year, either one-based or zero-based depending on
the actual method called. In the reform year this is the actual number
of days from January 1 (Julian) to the current date, whether Julian or
Gregorian.
=item * add, subtract
These are done in terms of duration, so that, for example, subtracting a
day from the reform date (Gregorian) gets you the day before the reform
date (Julian).
When months and/or years are involved, the result is modified from a
straight I<rata die> calculation to add or subtract the number of days
skipped by the reform. Without this modification, George Washington's
birthday of February 11 Julian would drift forward in the Gregorian
calendar as the difference between the two calendars increased. With
this modification, it is February 22 Gregorian regardless of the actual
days difference between the two calendars.
B<Note> that in versions C<0.12> and earlier this modification was
applied to B<all> durations. This produced anomalous (i.e. wrong)
results when adding or subtracting large numbers of days.
Beginning with version C<0.12_01> the modification is only applied to
months (and years, since years are folded into months when a
L<DateTime::Duration|DateTime::Duration> object is created.) The actual
order of operation is that specified by L<DateTime|DateTime>: the
C<days> component of the duration is applied first, then C<months> (with
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
can force it by doing something like
 $dt->add( months => 3 )->add( days => 5 );
to force months to be done first.
=item * strftime
This override allows selected methods of this class (i.e. not inherited
from DateTime) to be used in the C<'%{method_name}'> construction in
templates. The only method allowed at the moment is C<calendar_name>.
=item * gregorian_deviation( [$datetime] )
This method returns the difference in days between the Gregorian and the
Julian calendar. If the parameter $datetime is given, it will be used to
calculate the result; in this case this method can be used as a class
method.
This deviation increments on March 1 (Julian) of any year which is a
leap year in the Julian calendar but not the Gregorian calendar.
=item * julian_deviation( [$datetime] )
This method was added in version 0.13.
This method returns the difference in days between the Gregorian and the
Julian calendar. If the parameter $datetime is given, it will be used to
calculate the result; in this case this method can be used as a class
method.
This deviation increments on March 1 (Gregorian) of any year which is a
leap year in the Julian calendar but not the Gregorian calendar.
=item * DefaultReformDate
This static method returns a L<DateTime|DateTime> object representing
the default reform date. If called with an argument, the argument
becomes the new reform date, which is returned. The argument is either a
L<DateTime|DateTime> object (or something that can be converted into
one) or a reform date location name. See
L<SPECIFYING REFORM DATE|/SPECIFYING REFORM DATE> below for what kind of
arguments can be specified.
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
=item * Overloading
Addition, subtraction, and both string and numeric comparison are
overloaded. Objects with no date (that is, objects initialized as "date
generators") collate before objects with a date.
=back
=head1 SPECIFYING REFORM DATE
The reform date represents the first date the Gregorian calendar came
into use. It can be specified a number of different ways:
=over
=item * A DateTime object, or an object that can be converted into one.
=item * A location name (case-insensitive) from the following list:
 Italy -------------- 1582-10-15 # and some other Catholic countries
 France ------------- 1582-12-20
lib/DateTime/Calendar/Christian.pm view on Meta::CPAN
item. The string B<must> be the punctuated form; that is, C<'1752-9-14'>
will work, but C<'17520914'> will not. There must not be a zone
specification, and the year must not be signed.
=back
=head1 BUGS
=over
=item * There are problems with calendars switch to Gregorian before 200 AD or after about 4000 AD. Before 200 AD, this switch leads to duplication of dates. After about 4000 AD, there could be entire missing months. (The module can handle dates befo...
=item * There may be functions that give the wrong results for the year of the calendar reform. The function C<truncate()> is a known problem, and C<today()> may be a problem. If you find any more problems, please let me know.
=back
=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.
Please report bugs to
L<https://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Calendar-Christian>,
t/06leapyears.t view on Meta::CPAN
                                         day   => 1,
                                         reform_date => $rd );
ok( $d->is_leap_year, 'difficult case 4' );
$rd = DateTime->new( year => 1584, month => 3, day => 5 );
$d = DateTime::Calendar::Christian->new( year  => 1584,
                                         month => 1,
                                         day   => 1,
                                         reform_date => $rd );
ok( ! $d->is_leap_year, 'no leap day during calendar reform' );
$rd = DateTime->new( year => 1700, month => 3, day => 5 );
$d = DateTime::Calendar::Christian->new( year  => 1700,
                                         month => 1,
                                         day   => 1,
                                         reform_date => $rd );
ok( ! $d->is_leap_year, 'no leap day during calendar reform' );
done_testing;
# ex: set textwidth=72 :
my ($d, $d2);
$d = DateTime::Calendar::Christian->new( year  => 1582,
                                         month => 10,
                                         day   => 4,
                                         hour  => 22 );
$d2 = $d->clone;
$d2->add( hours => 3 );
is( $d2->datetime, '1582-10-15T01:00:00', 'adding hours around calendar change' );
$d2->subtract( hours => 3 );
is( $d2->datetime, '1582-10-04J22:00:00', 'subtracting hours around calendar change' );
$d2 = $d->clone;
$d2->add( days => 3 );
is( $d2->ymd, '1582-10-17', 'adding days around calendar change' );
$d2->subtract( days => 3 );
is( $d2->ymd, '1582-10-04', 'subtracting days around calendar change' );
$d2 = $d->clone;
$d2->add( months => 3 );
is( $d2->ymd, '1583-01-14', 'adding months around calendar change' );
$d2->subtract( months => 3 );
is( $d2->ymd, '1582-10-04', 'subtracting months around calendar change' );
$d2 = $d->clone;
$d2->add( years => 3 );
is( $d2->ymd, '1585-10-14', 'adding years around calendar change' );
$d2->subtract( years => 3 );
is( $d2->ymd, '1582-10-04', 'subtracting years around calendar change' );
$d2 = $d->clone;
$d2->add( years => 300 );
is( $d2->ymd, '1882-10-14', 'adding centuries around calendar change' );
$d2->subtract( years => 300 );
is( $d2->ymd, '1582-10-04', 'subtracting centuries around calendar change' );
$d = DateTime::Calendar::Christian->new( year  => 1285,
                                         month => 1,
                                         day   => 1 );
$d->add( years => 300 );
is( $d->ymd, '1585-01-11', 'adding centuries around calendar change' );
$d->subtract( years => 300 );
is( $d->ymd, '1285-01-01', 'subtracting centuries around calendar change' );
$d = DateTime::Calendar::Christian->new(
        year => 1582, month => 10, day => 30 );
$d2 = DateTime::Calendar::Christian->new(
        year => 1582, month => 10, day => 1 );
my $dur = $d - $d2;
isa_ok( $dur, 'DateTime::Duration' );
is( $dur->delta_days, 19, 'datetime - datetime' );
t/11month.t view on Meta::CPAN
is( $d->ymd, '2003-06-30', 'ordinary month');
$d = DateTime::Calendar::Christian->last_day_of_month(
        year  => 1500, month => 2 );
is( $d->ymd, '1500-02-29', 'Julian leap month');
$d = DateTime::Calendar::Christian->last_day_of_month(
        year  => 1582, month => 10 );
is( $d->ymd, '1582-10-31', 'month of calendar reform');
$r = DateTime::Calendar::Christian->new(
        year  => 1650, month => 3, day => 1 );
$d = DateTime::Calendar::Christian->last_day_of_month(
        year  => 1650, month => 2, reform_date => $r );
is( $d->ymd, '1650-02-18', 'incomplete month');
$r = DateTime::Calendar::Christian->new(
t/13strftime.t view on Meta::CPAN
use Test::More 0.88;	# Because of done_testing();
use DateTime::Calendar::Christian;
my $gw = DateTime::Calendar::Christian->new(
    year	=> 1732,
    month	=> 2,
    day		=> 22,
);
is $gw->strftime( '%Y-%m-%d %{calendar_name}' ), '1732-02-22 Gregorian',
    q<George Washington's birthday, Gregorian>;
$gw = DateTime::Calendar::Christian->new(
    year	=> 1732,
    month	=> 2,
    day		=> 11,
    reform_date	=> 'uk',
);
is $gw->strftime( '%Y-%m-%d %{calendar_name}' ), '1732-02-11 Julian',
    q<George Washington's birthday, Julian>;
done_testing;
1;
# ex: set textwidth=72 :
    ok(
        !$dt->is_between( $dt, _add( $dt, 1 ) ),
        'not is_between same datetime and 1 minute after'
    );
    ok(
        !$dt->is_between( _add( $dt, -1 ), $dt ),
        'not is_between 1 minute before and same datetime'
    );
}
foreach my $info (
    [ 1500, 365, 0 ],	# 1500 is a leap year in the Julian calendar
    [ 1500, 366, 1 ],
    [ 1501, 365, 1 ],
    [ 1700, 365, 1 ],	# 1700 is not a leap year in the Gregorian calendar
    [ 1704, 365, 0 ],	# but 1704 is
    [ 1704, 366, 1 ],
) {
    my ( $year, $yday, $is_last ) = @{ $info };
    my $dt = DateTime::Calendar::Christian->from_day_of_year(
	year		=> $year,
	day_of_year	=> $yday,
    );
    # OK, I'm cheating by bundling all the is_last_day_* tests together,
    # but I think I have a meaningful test of each.
    cmp_ok $dt->is_last_day_of_month, '==', $is_last,
	sprintf '%04d-%03d (%s) %s the last day of the month',
	$year, $yday, $dt->calendar_name, $is_last ? 'is' : 'is not';
    cmp_ok $dt->is_last_day_of_quarter, '==', $is_last,
	sprintf '%04d-%03d (%s) %s the last day of the quarter',
	$year, $yday, $dt->calendar_name, $is_last ? 'is' : 'is not';
    cmp_ok $dt->is_last_day_of_year, '==', $is_last,
	sprintf '%04d-%03d (%s) %s the last day of the year',
	$year, $yday, $dt->calendar_name, $is_last ? 'is' : 'is not';
}
foreach my $info (
    [ 1500, 2, 29 ],	# 1500 is a leap year in the Julian calendar
    [ 1501, 2, 28 ],
    [ 1700, 2, 28 ],	# 1700 is not a leap year in the Gregorian calendar
    [ 1704, 2, 29 ],	# but 1704 is
) {
    my ( $year, $mon, $len ) = @{ $info };
    my $dt = DateTime::Calendar::Christian->new(
	year	=> $year,
	month	=> $mon,
	day	=> 1,
    );
    cmp_ok $dt->month_length, '==', $len,
    sprintf 'Month %04d-%02d (%s) is %d days long', $year, $mon,
    $dt->calendar_name, $len;
}
foreach my $info (
    [ 1200, 91 ],
    [ 1500, 91 ],
    [ 1501, 90 ],
    [ 1600, 91 ],
    [ 1601, 90 ],
    [ 1700, 90 ],
) {
    my ( $year, $len ) = @{ $info };
    my $dt = DateTime::Calendar::Christian->new(
	year	=> $year,
	month	=> 1,
	day	=> 1,
    );
    cmp_ok $dt->quarter_length( 1 ), '==', $len,
	sprintf 'Length of first quarter of %04d (%s) is %d days',
	$year, $dt->calendar_name, $len;
}
foreach my $info (
    [ 1500, '1500-01-01T00:00:00' ],
    [ 1600, '1600-01-01T00:00:00' ],
) {
    my ( $year, $str ) = @{ $info };
    my $dt = DateTime::Calendar::Christian->new(
	year	=> $year,
	month	=> 1,
	day	=> 1,
    );
    cmp_ok $dt->stringify, 'eq', $str,
	sprintf q<January 1 %04d (%s) stringifies by default to '%s'>,
	$year, $dt->calendar_name, $str;
    cmp_ok $dt->rfc3339, 'eq', $str,
	sprintf q<January 1 %04d (%s) per rfc3339 is '%s'>,
	$year, $dt->calendar_name, $str;
}
foreach my $info (
    [ 1200, 366 ],
    [ 1500, 366 ],
    [ 1501, 365 ],
    [ 1600, 366 ],
    [ 1601, 365 ],
    [ 1700, 365 ],
) {
    my ( $year, $len ) = @{ $info };
    my $dt = DateTime::Calendar::Christian->new(
	year	=> $year,
	month	=> 1,
	day	=> 1,
    );
    cmp_ok $dt->year_length, '==', $len,
	sprintf 'Length of year %04d (%s) is %d days',
	$year, $dt->calendar_name, $len;
}
done_testing;
sub _add {
    shift->clone->add( minutes => shift );
}
1;