Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Calculate down time of devices in prime time (only working hours, excluding p_holidays)

by albertc (Initiate)
on Oct 13, 2003 at 08:00 UTC ( [id://298788]=perlquestion: print w/replies, xml ) Need Help??

albertc has asked for the wisdom of the Perl Monks concerning the following question:

I have up & down datetime data for devices, I need a function that will provide the downtime within the primetime period. Input will be d_time, u_time, stime (starting time for Primetime, 08:00:00), etime (endtime for PrimeTime, 18:59:59). The function also needs to remove downtime that occured on a public holiday and over weekends! Public holidays will be read from mysql table with Datetime record of each public holiday. Hope you can help!
  • Comment on Calculate down time of devices in prime time (only working hours, excluding p_holidays)

Replies are listed 'Best First'.
Re: Calculate down time of devices in prime time (only working hours, excluding p_holidays)
by tachyon (Chancellor) on Oct 13, 2003 at 08:22 UTC

    Hope you can help!

    How Exactly? Do you have a specific issue or just a loose spec. If you have specific coding issues you are likely to get rapid help. If you don't know where to start you probably need to hire someone. If the question is can Perl do this the answer is yes. If you are looking libraries to do most of the work see Date::

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Calculate down time of devices in prime time (only working hours, excluding p_holidays)
by phydeauxarff (Priest) on Oct 13, 2003 at 12:27 UTC
    I just recently needed a similar report of business days that have passed for reporting and finally found date::calendar

    The following is an example of taking two days and figuring out the delta of business days.

    #!/usr/bin/perl use strict; use Date::Calendar; my $date_1 = [2003,9,24]; my $date_2 = [2003,10,9]; my $flag_1 = '1'; my $flag_2 = '0'; my $calendar = Date::Calendar->new({}); my $days = $calendar->delta_workdays($date_1,$date_2,$flag_1,$flag_2); print "$days\n";

    There is also the ability to build your holiday list as well.

    There is also Date::Business but I haven't given that a shot yet.

Re: Calculate down time of devices in prime time (only working hours, excluding p_holidays)
by moxliukas (Curate) on Oct 13, 2003 at 08:16 UTC

    I think Date::Calc module would be of some use for you. At least it allows you to calculate time intervals, add them, etc.

      hola moxiliukas;

      unfortunately, Date::Calc cannot contend with business days, nor holidays. if you wanted to use Date::Calc, you'd have to implement that stuff yourself. great if you've lost your hair shirt...;-)

      ttfn
      ...wufnik

      -- in the world of the mules there are no rules --

        Sure it can. Check out: check_business_date, Standard_to_Business, Business_to_Standard, Easter_Sunday & the recipes (especially #10 solution #2).

        It's not necessarily the easiest way to do it though. ;-)

Re: Calculate down time of devices in prime time (only working hours, excluding p_holidays)
by hossman (Prior) on Oct 13, 2003 at 18:01 UTC
    Time::Available was recently uploaded to CPAN. No idea how usefull it may be.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://298788]
Approved by robartes
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found