Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: Determining if I have a particular Friday off

by thmsdrew (Scribe)
on Nov 06, 2012 at 14:55 UTC ( #1002498=note: print w/replies, xml ) Need Help??

in reply to Re: Determining if I have a particular Friday off
in thread Determining if I have a particular Friday off

Hey, been busy lately but I finally addressed the problem you pointed out as follows:

#!/usr/bin/perl use strict; use warnings; use Date::Calc qw(check_date Add_Delta_Days Monday_of_Week Week_of_Yea +r Compress Today Date_to_Text Weeks_in_Year); if (check_date(@ARGV)) { # If there are 52 weeks in the year, I have odd Fridays off. # If there are 53, I have even Fridays off. my $mod = (Weeks_in_Year($ARGV[1]) eq 52) ? 2 : 1; my @friday = Add_Delta_Days(Monday_of_Week(Week_of_Year(@ARGV)), 4 +); my ($week, $year) = Week_of_Year(@friday); my $present = Compress(@friday) > Compress(Today()); printf "You %s have %s off.\n", ($present ? "DO" : "DID") . ($week % $mod ? "" : "N'T"), Date_to_Text(@friday); } else { print "Usage.\n"; }

Replies are listed 'Best First'.
Re^3: Determining if I have a particular Friday off
by hbm (Hermit) on Nov 06, 2012 at 16:55 UTC
    my $mod = (Weeks_in_Year($ARGV[1]) eq 52) ? 2 : 1; ... ($present ? "DO" : "DID") . ($week % $mod ? "" : "N'T")

    Hmmm. When $mod is 1, % is always zero - and you "DON'T/DIDN'T" have off.

      Hmm yeah, I wasn't thinking. This is a weird case, I'll have to think more about it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002498]
[Discipulus]: dear brother karl has "Furthermore I consider that Donald Trump must be impeached as soon as possible" in his sig
[erix]: ah, thanks Discipulus
[1nickt]: erix perhaps you could kindly point out your technique to roho and everyone will be happy.
[Discipulus]: but i'm also animalist, so i' hirted by 1nickt's sig: The way forward always starts with a mammal test... grin..
[erix]: I might if I did remember. It's probably somewhere in the site docs
[uhClem]: I don't favor that sort of thing around here but the place for our politics is wherever we live.
[uhClem]: And besides, the objection to it was off-topic.
[Discipulus]: 1nickt hide signature is a positive action; i think is not a solution here

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2017-06-22 12:36 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.