Skip Menu |
 

This queue is for tickets about the Business-Hours CPAN distribution.

Report information
The Basics
Id: 57086
Status: new
Priority: 0/
Queue: Business-Hours

People
Owner: Nobody in particular
Requestors: mpeverill [...] pplm.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: between method
Date: Fri, 30 Apr 2010 10:53:27 -0400
To: <bug-business-hours [...] rt.cpan.org>
From: "Peverill, Matthew" <mpeverill [...] pplm.org>
Download (untitled) / with headers
text/plain 3.1k
Good morning, I'm trying to calculate the number of business seconds between two linux epoch formatted datetimes with the between method. I'm using Business-Hours-0.09 off of CPAN. The method seems to be returning -1 no matter what dates I feed it. Is this expected / has it been addressed in the development version? I'd love to help get this fixed; it would really help us get our reporting cleaned up. Here is my code: #!/usr/bin/perl use strict; use DateTime; use Business::Hours; my %ISTsched = ( 0 => { Name => 'Sunday', Start => undef, End => undef }, 1 => { Name => 'Monday', Start => '7:30', End => '17:00' }, 2 => { Name => 'Tuesday', Start => '7:30', End => '17:00' }, 3 => { Name => 'Wednesday', Start => '7:30', End => '17:00' }, 4 => { Name => 'Thursday', Start => '7:30', End => '17:00' }, 5 => { Name => 'Friday', Start => '7:30', End => '17:00' }, 6 => { Name => 'Saturday', Start => '7:30', End => '15:30' }, ); my $bdate = DateTime->new( year => 2010, month => 4, day => 30, hour => 7, minute => 31, time_zone => 'America/New_York'); my $edate = DateTime->new( year => 2010, month => 4, day => 30, hour => 10, minute => 30, time_zone => 'America/New_York'); my $bepoch = $bdate->epoch; my $eepoch = $edate->epoch; print "Raw Times:\n"."begin:\t"."$bdate\t"."$bepoch\n"."end:\t"."$edate\t"."$eepoch \n\n"; my $hours = Business::Hours->new(); $hours->business_hours(%ISTsched); my $pbepoch = $hours->first_after($bepoch); my $peepoch = $hours->first_after($eepoch); my $pbdate = DateTime->from_epoch( epoch => $pbepoch, time_zone => 'America/New_York' ); my $pedate = DateTime->from_epoch( epoch => $peepoch, time_zone => 'America/New_York' ); print "Returns:\n"."begin:\t"."$pbdate\t"."$pbepoch\n"."end:\t"."$pedate\t"."$ peepoch \n\n"; my $interval = $hours->between($pbepoch,$peepoch); print "Interval:\t$interval\n"; Here are two examples of output, one with a value outside of business hours being fed in to first_after (which seems to work fine) and one without. #1 scripts]# ./bhourtest Raw Times: begin: 2010-04-29T18:30:00 1272580200 end: 2010-04-30T10:30:00 1272637800 Returns: begin: 2010-04-30T07:30:00 1272627000 end: 2010-04-30T10:30:00 1272637800 Interval: -1 #2 scripts]# ./bhourtest Raw Times: begin: 2010-04-30T07:31:00 1272627060 end: 2010-04-30T10:30:00 1272637800 Returns: begin: 2010-04-30T07:31:00 1272627060 end: 2010-04-30T10:30:00 1272637800 Interval: -1 Matt Peverill Applications Specialist Planned Parenthood League of Massachusetts Phone: 617-616-1656 Fax: 617-616-1665 Let's be friends. Find PPLM on Facebook <blocked::http://www.facebook.com/plannedparenthoodma> and MySpace <blocked::http://www.myspace.com/plannedparenthoodma> or visit us at www.pplm.org <http://www.pplm.org> .
Download (untitled) / with headers
text/html 13.5k

Message body is not shown because it is too large.

Subject: RE: [rt.cpan.org #57086] AutoReply: between method
Date: Fri, 30 Apr 2010 14:28:59 -0400
To: <bug-Business-Hours [...] rt.cpan.org>
From: "Peverill, Matthew" <mpeverill [...] pplm.org>
Download (untitled) / with headers
text/plain 5.3k
I fixed this. The problem was that first_after was executing for_timespan, and then between did not run it again because $self->{'start'} etc. was already set. I added: ... my $hours = Business::Hours->new(); $hours->business_hours(%ISTsched); my $pbepoch = $hours->first_after($bepoch); my $peepoch = $hours->first_after($eepoch); $hours->for_timespan( Start => $bepoch, End => $eepoch); #THIS IS THE NEW LINE my $pbdate = DateTime->from_epoch( epoch => $pbepoch, time_zone => 'America/New_York' ); my $pedate = DateTime->from_epoch( epoch => $peepoch, time_zone => 'America/New_York' ); print "Returns:\n"."begin:\t"."$pbdate\t"."$pbepoch\n"."end:\t"."$pedate\t"."$peepoch \n\n"; ... And everything worked. I'm all set, but if you're interested in further development maybe first_after could be written in such a way to keep the timespan clean? -Matt Matt Peverill Applications Specialist Planned Parenthood League of Massachusetts Phone: 617-616-1656 Fax: 617-616-1665 Join the Sexual Health Matters Revolution Visit: www.pplm.org Show quoted text
-----Original Message----- From: Bugs in Business-Hours via RT [mailto:bug-Business-Hours@rt.cpan.org] Sent: Friday, April 30, 2010 11:01 AM To: Peverill, Matthew Subject: [rt.cpan.org #57086] AutoReply: between method Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding: "between method", a summary of which appears below. There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #57086]. Your ticket is accessible on the web at: http://rt.cpan.org/Ticket/Display.html?id=57086 Please include the string: [rt.cpan.org #57086] in the subject line of all future correspondence about this issue. To do so, you may reply to this message. Thank you, bug-Business-Hours@rt.cpan.org ------------------------------------------------------------------------- Good morning, I'm trying to calculate the number of business seconds between two linux epoch formatted datetimes with the between method. I'm using Business-Hours-0.09 off of CPAN. The method seems to be returning -1 no matter what dates I feed it. Is this expected / has it been addressed in the development version? I'd love to help get this fixed; it would really help us get our reporting cleaned up. Here is my code: #!/usr/bin/perl use strict; use DateTime; use Business::Hours; my %ISTsched = ( 0 => { Name => 'Sunday', Start => undef, End => undef }, 1 => { Name => 'Monday', Start => '7:30', End => '17:00' }, 2 => { Name => 'Tuesday', Start => '7:30', End => '17:00' }, 3 => { Name => 'Wednesday', Start => '7:30', End => '17:00' }, 4 => { Name => 'Thursday', Start => '7:30', End => '17:00' }, 5 => { Name => 'Friday', Start => '7:30', End => '17:00' }, 6 => { Name => 'Saturday', Start => '7:30', End => '15:30' }, ); my $bdate = DateTime->new( year => 2010, month => 4, day => 30, hour => 7, minute => 31, time_zone => 'America/New_York'); my $edate = DateTime->new( year => 2010, month => 4, day => 30, hour => 10, minute => 30, time_zone => 'America/New_York'); my $bepoch = $bdate->epoch; my $eepoch = $edate->epoch; print "Raw Times:\n"."begin:\t"."$bdate\t"."$bepoch\n"."end:\t"."$edate\t"."$eepoch \n\n"; my $hours = Business::Hours->new(); $hours->business_hours(%ISTsched); my $pbepoch = $hours->first_after($bepoch); my $peepoch = $hours->first_after($eepoch); my $pbdate = DateTime->from_epoch( epoch => $pbepoch, time_zone => 'America/New_York' ); my $pedate = DateTime->from_epoch( epoch => $peepoch, time_zone => 'America/New_York' ); print "Returns:\n"."begin:\t"."$pbdate\t"."$pbepoch\n"."end:\t"."$pedate\t"."$ peepoch \n\n"; my $interval = $hours->between($pbepoch,$peepoch); print "Interval:\t$interval\n"; Here are two examples of output, one with a value outside of business hours being fed in to first_after (which seems to work fine) and one without. #1 scripts]# ./bhourtest Raw Times: begin: 2010-04-29T18:30:00 1272580200 end: 2010-04-30T10:30:00 1272637800 Returns: begin: 2010-04-30T07:30:00 1272627000 end: 2010-04-30T10:30:00 1272637800 Interval: -1 #2 scripts]# ./bhourtest Raw Times: begin: 2010-04-30T07:31:00 1272627060 end: 2010-04-30T10:30:00 1272637800 Returns: begin: 2010-04-30T07:31:00 1272627060 end: 2010-04-30T10:30:00 1272637800 Interval: -1 Matt Peverill Applications Specialist Planned Parenthood League of Massachusetts Phone: 617-616-1656 Fax: 617-616-1665 Let's be friends. Find PPLM on Facebook <blocked::http://www.facebook.com/plannedparenthoodma> and MySpace <blocked::http://www.myspace.com/plannedparenthoodma> or visit us at www.pplm.org <http://www.pplm.org> .


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.