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)



From mpeverill [...] pplm.org Fri Apr 30 11: 01:02 2010
X-Originalarrivaltime: 30 Apr 2010 14:59:15.0806 (UTC) FILETIME=[B3C0DFE0:01CAE875]
MIME-Version: 1.0
X-Spam-Status: No, score=-10.598 tagged_above=-99.9 required=10 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-8] autolearn=ham
Content-Class: urn:content-classes:message
X-Spam-Flag: NO
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Message-ID: <6E8B706FB0DD6042BCDCEAD680F5CABD0134BF47 [...] ppsbexch02.pplm.local>
Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CAE874.E49E43F6"
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-MS-Tnef-Correlator:
X-Spam-Score: -10.598
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id C6FDC240650 for <cpan-bug+business-hours [...] hipster.bestpractical.com>; Fri, 30 Apr 2010 11:01:02 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D-Yg5-W+APbW for <cpan-bug+business-hours [...] hipster.bestpractical.com>; Fri, 30 Apr 2010 11:00:59 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id E65312405BE for <bug-business-hours [...] rt.cpan.org>; Fri, 30 Apr 2010 11:00:58 -0400 (EDT)
Received: (qmail 15779 invoked by uid 103); 30 Apr 2010 15:01:07 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 30 Apr 2010 15:01:07 -0000
Received: from exprod5og113.obsmtp.com (HELO exprod5og113.obsmtp.com) (64.18.0.26) by 16.mx.develooper.com (qpsmtpd/0.80) with SMTP; Fri, 30 Apr 2010 08:00:59 -0700
Received: from source ([74.8.119.75]) by exprod5ob113.postini.com ([64.18.4.12]) with SMTP ID DSNKS9rwqCnVudFrJVGJOqzgMRPtGXndi1Oh [...] postini.com; Fri, 30 Apr 2010 08:00:58 PDT
Received: from ppsbexch02.pplm.local ([10.0.0.70]) by outbound.pplm.org with Microsoft SMTPSVC(6.0.3790.3959); Fri, 30 Apr 2010 10:59:15 -0400
Delivered-To: cpan-bug+business-hours [...] hipster.bestpractical.com
Subject: between method
Return-Path: <mpeverill [...] pplm.org>
Thread-Index: AcrodOQiy/j9Eu8QQJ6uuwHnbXWxBw==
X-RT-Mail-Extension: business-hours
X-Original-To: cpan-bug+business-hours [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Fri, 30 Apr 2010 10:53:27 -0400
X-Spam-Level:
Thread-Topic: between method
X-MS-Has-Attach:
X-Mimeole: Produced By Microsoft Exchange V6.5
To: <bug-business-hours [...] rt.cpan.org>
From: "Peverill, Matthew" <mpeverill [...] pplm.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: us-ascii
Content-Length: 3228
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> .
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: us-ascii
Content-Length: 13826
Download (untitled) / with headers
text/html 13.5k

Message body is not shown because it is too large.

From mpeverill [...] pplm.org Fri Apr 30 14: 29:04 2010
X-Originalarrivaltime: 30 Apr 2010 18:29:01.0133 (UTC) FILETIME=[01315FD0:01CAE893]
MIME-Version: 1.0
X-Spam-Status: No, score=-10.599 tagged_above=-99.9 required=10 tests=[AWL=0.000, BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-6782-1272639675-1673.57086-3-0 [...] rt.cpan.org>
Content-Class: urn:content-classes:message
X-Spam-Flag: NO
References: <RT-Ticket-57086 [...] rt.cpan.org> <6E8B706FB0DD6042BCDCEAD680F5CABD0134BF47 [...] ppsbexch02.pplm.local> <rt-3.8.HEAD-6782-1272639675-1673.57086-3-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Content-Type: text/plain; charset="utf-8"
Message-ID: <6E8B706FB0DD6042BCDCEAD680F5CABD0134BF6D [...] ppsbexch02.pplm.local>
X-MS-Tnef-Correlator:
X-RT-Original-Encoding: utf-8
X-Spam-Score: -10.599
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B1C1C2406C4 for <cpan-bug+Business-Hours [...] hipster.bestpractical.com>; Fri, 30 Apr 2010 14:29:04 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ltSGXdY8NOp1 for <cpan-bug+Business-Hours [...] hipster.bestpractical.com>; Fri, 30 Apr 2010 14:28:59 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id D0B032406BA for <bug-Business-Hours [...] rt.cpan.org>; Fri, 30 Apr 2010 14:28:58 -0400 (EDT)
Received: (qmail 28842 invoked by uid 103); 30 Apr 2010 18:29:09 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 30 Apr 2010 18:29:09 -0000
Received: from exprod5og106.obsmtp.com (HELO exprod5og106.obsmtp.com) (64.18.0.182) by 16.mx.develooper.com (qpsmtpd/0.80) with SMTP; Fri, 30 Apr 2010 11:29:05 -0700
Received: from source ([74.8.119.75]) by exprod5ob106.postini.com ([64.18.4.12]) with SMTP ID DSNKS9shbgTdYswh2D97+yoW3vtGyCQfS6BL [...] postini.com; Fri, 30 Apr 2010 11:29:04 PDT
Received: from ppsbexch02.pplm.local ([10.0.0.70]) by outbound.pplm.org with Microsoft SMTPSVC(6.0.3790.3959); Fri, 30 Apr 2010 14:29:01 -0400
Delivered-To: cpan-bug+Business-Hours [...] hipster.bestpractical.com
Subject: RE: [rt.cpan.org #57086] AutoReply: between method
Return-Path: <mpeverill [...] pplm.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Business-Hours [...] hipster.bestpractical.com
X-RT-Mail-Extension: business-hours
Thread-Index: Acrodf3GsRRbn2NfRz2ZnnlXAX9CJAAHIWUw
Date: Fri, 30 Apr 2010 14:28:59 -0400
X-Spam-Level:
X-MS-Has-Attach:
Thread-Topic: [rt.cpan.org #57086] AutoReply: between method
X-Mimeole: Produced By Microsoft Exchange V6.5
To: <bug-Business-Hours [...] rt.cpan.org>
Content-Transfer-Encoding: base64
From: "Peverill, Matthew" <mpeverill [...] pplm.org>
RT-Message-ID: <rt-3.8.HEAD-6788-1272652156-232.57086-0-0 [...] rt.cpan.org>
Content-Length: 5448
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.