[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



-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@gmail.com>
To: pm_groups@pm.org
References: <445802EC.5030102@jays.net>

On 5/2/06, Jay Hannah <jay@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@pm.org

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