Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
L~R, thanks for the full framework! I was headed down the same path and manipulated the examples from the Panther to work with 24 hours per day:
#!/usr/bin/perl -w use strict; my %base_hours = ( sun => 0, mon => 24, tue => 48, wed => 72 , thu => +96, fri => 120, sat => 144 ); my $vector = interval_parse("Sat 9-17, Sun 9-17"); my $bits = unpack("b*", $vector); print $bits, "\n"; sub interval_parse { my ($interval_sequence) = @_; my ($time_range) = ""; foreach my $day_hours (split /,/, $interval_sequence) { my ($day, $from, $to) = ($day_hours =~ /([A-Za-z]+).*(\d+)-(\d+ +)/); my $base = $base_hours{lc $day}; $from += $base; $to += $base; for (my $i = $from; $i < $to; $i++) { vec($time_range, $i, 1) = 1; } } return($time_range); }
Thanks for the pointer!

-Nitrox


In reply to Re: Re: Representing windows of time in a string by Nitrox
in thread Representing windows of time in a string by Nitrox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found