Brian Cassidy > DateTime-BusinessHours-2.03 > DateTime::BusinessHours

Download:
DateTime-BusinessHours-2.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 2.03   Source  

NAME ^

DateTime::BusinessHours - An object that calculates business days and hours

SYNOPSIS ^

    my $d1 = DateTime->new( year => 2007, month => 10, day => 15 );
    my $d2 = DateTime->now;

    my $test = DateTime:::BusinessHours->new(
        datetime1 => $d1,
        datetime2 => $d2,
        worktiming => [ 9, 17 ], # 9am to 5pm
        # lunch from 12 to 1
        # worktiming => [ [ 9, 12 ], [ 13, 17 ] ],
        weekends => [ 6, 7 ], # Saturday and Sunday
        holidays => [ '2007-10-31', '2007-12-24' ],
        holidayfile => 'holidays.txt'
        # holidayfile is a text file with each date in a new line
        # in the format yyyy-mm-dd  
    );

    # total business hours
    print $test->gethours, "\n";
    # total business days, based on the number of business hours in a day
    print $test->getdays, "\n"; 

DESCRIPTION ^

BusinessHours a class for caculating the business hours between two DateTime objects. It can be useful in situations like escalation where an action has to happen after a certain number of business hours.

METHODS ^

new( %args )

This class method accepts the following arguments as parameters:

calculate( )

This will force a recalculation of the business hours and days. useful if you've changed any values (datetime1, datetime2, worktiming, etc) or updated the holiday file

getdays( )

Returns the number of business days

gethours( )

Returns the number of business hours.

INSTALLATION ^

To install this module, run the following commands:

        perl Makefile.PL
        make
        make test
        make install

SUPPORT AND DOCUMENTATION ^

After installing, you can find documentation for this module with the perldoc command.

    perldoc DateTime::BusinessHours

You can also look for information at:

    RT, CPAN's request tracker
        http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-BusinessHours

    AnnoCPAN, Annotated CPAN documentation
        http://annocpan.org/dist/DateTime-BusinessHours

    CPAN Ratings
        http://cpanratings.perl.org/d/DateTime-BusinessHours

    Search CPAN
        http://search.cpan.org/dist/DateTime-BusinessHours

AUTHOR ^

Antano Solar John <solar345@gmail.com>

MAINTAINER ^

Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (c) 2007-2011 Antano Solar John, 2012-2013 by Brian Cassidy

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: