[Omaha.pm] [Fwd: Re: [pm_groups] Calculate next meeting date]

Jay Hannah jay at jays.net
Wed May 3 14:55:14 PDT 2006


-laugh- !!

j


-------- Original Message --------
Subject: Re: [pm_groups] Calculate next meeting date
Date: Tue, 2 May 2006 20:28:50 -0600
From: Marcelo E. Magallón <marcelo.magallon at gmail.com>
To: pm_groups at pm.org
References: <445802EC.5030102 at jays.net>

On 5/2/06, Jay Hannah <jay at jays.net> wrote:

> This is a pretty slick combination of Date::Calc and Class::Date, IMHO:

Cute...

> Anyone have a tighter version?  :)

Are you seriously asking for golf?  Fooooooore!

--------------------------------- 8< ---------------------------------
#!/usr/bin/perl -l

use strict; # just for the fun of ...
use warnings; # ... making golf funnier
use POSIX qw/mktime/;

my $target_wday = shift; # 0 is Sunday
my $target_index = shift; # 1 is the first, 2 the second, ...

my ($d, $m, $y, $first, $day) = (localtime)[3..5];
for (0 .. 1)
{
    $first = (localtime mktime(0, 0, 0, 0, $m, $y))[6];
    $day = 7*($target_index-1)+1+(6-$first+$target_wday)%7;
    $day < $d ? $m++ : last;
}
print scalar localtime mktime(0, 0, 0, $day, $m, $y);
--------------------------------- >8 ---------------------------------

Not really golf, but it's going that way...

Marcelo
-- 
Request pm.org Technical Support via support at pm.org

pm_groups mailing list
pm_groups at pm.org
http://mail.pm.org/mailman/listinfo/pm_groups


More information about the Omaha-pm mailing list