Subject: | Bug in DateTime::Event::Jewish::Parshah for dates 15-21 Adar 5785 |
Date: | Wed, 17 Jul 2013 23:08:48 -0400 |
To: | bug-DateTime-Event-Jewish [...] rt.cpan.org |
From: | Dave Lerner - CPAN <hxr99v9mxq [...] snkmail.com> |
I'm resending this, since the original message seems to have been lost.
-----
The module DateTime::Event::Jewish::Parshah outputs the wrong Parashah
for the date range 15-21 Adar 5785.
The module outputs the Parashah "Vayakhel/Pekudei", but the correct
Parashah is "Vayakhel", as determined by checking several other sources.
The problem appears to be in the following code in sub parshah:
-----
if($parshahNumber==22) { #Vayakhel
my $pesachDays = $pesach->{rd_days};
$combined =1 if( ($pesachDays - $workingDays) < 28);
next LOOP;
}
-----
I determined empirically that changing " < 28" to " < 22" fixes the
problem for 5785, and works for all 14 year types, for both the Israel
and Diaspora cases, at least in the context of my test, which compares
the results against the downloadable spreadsheet
<http://individual.utoronto.ca/kalendis/hebrew/Torah-Portions.xls>
located at <http://individual.utoronto.ca/kalendis/hebrew/parshah.htm>.
But there may be a better solution.
-----
Perl version: 5.14.2
DateTime::Event::Jewish::Parshah version: 0.01
Operating system: Ubuntu 12.04.2
Kernel: Linux 3.8.0-26-generic #38~precise2-Ubuntu SMP x86_64
-----
-----
Code that demonstrates bug:
-----
#!/usr/bin/perl
# Demonstrate bug in DateTime::Event::Jewish::Parshah.
# For the dates 5785-12-15 through 5785-12-21,
# the parashah output is 'Vayakhel/Pekudei',
# but the correct parashah is 'Vayakhel'.
use DateTime::Event::Jewish::Parshah();
my $date;
my $parashah;
for (my $day = 15; $day <= 21; $day++) {
$date = DateTime::Calendar::Hebrew->new(year=>5785,month=>12,day=>$day);
$parashah = DateTime::Event::Jewish::Parshah::parshah($date);
# Parashah printed is 'Vayakhel/Pekudei', but should be 'Vayakhel'.
print "Parashah for @{[$date->ymd()]} is $parashah\n";
}
-----
Suggested patch:
-----
33c33
< our $VERSION = '0.01';
---
Show quoted text
> our $VERSION = '0.02';
175c175
< $combined =1 if( ($pesachDays - $workingDays) < 28);
---
Show quoted text> $combined =1 if( ($pesachDays - $workingDays) < 22);
-----
Thanks for a useful module.
Dave Lerner