[sf-lug] upcoming_meetings: Re: [SF-LUG Meets This Sunday 2020.01.02 @ 11:00am]

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sun Feb 23 08:32:15 PST 2020


Or one could use(/write) a program that does the useful.

$ echo $(upcoming_meetings 1st su | sed -e '/^2022/q') | fold -s -w 72
2020-03-01 2020-04-05 2020-05-03 2020-06-07 2020-07-05 2020-08-02
2020-09-06 2020-10-04 2020-11-01 2020-12-06 2021-01-03 2021-02-07
2021-03-07 2021-04-04 2021-05-02 2021-06-06 2021-07-04 2021-08-01
2021-09-05 2021-10-03 2021-11-07 2021-12-05 2022-01-02
$

Hmmm, I think I put that program up somewhere on 'da Interwebs.
I need to put it (and others) where more accessible/findable.
On my to do list, ... just not that close to top priority
presently.

Well, in the meantime, for the curious, see below:
$ expand -t 4 ~/bin/upcoming_meetings
#!/usr/bin/perl
$^W=1;
use strict;

# vi(1) :se tabstop=4

use Date::Calc qw(
         Today
         Nth_Weekday_of_Month_Year
     )
;

sub usage{
     die("usage: $0: {1st,2nd,3rd,[45]th,last}  
{Sun,Mon,Tues,Wednes,Thurs,Fri,Satur}day\n");
};

if($#ARGV<1){
     &usage;
};

$_=$ARGV[0];
my $n;
if(/^1(?:st)?$/io){     $n=1;
}elsif(/^2(?:nd)?$/io){ $n=2;
}elsif(/^3(?:rd)?$/io){ $n=3;
}elsif(/^4(?:th)?$/io){ $n=4;
}elsif(/^5(?:th)?$/io){ $n=5;
}elsif(/^last$/io){     $n='l';
}else{
     &usage;
};

$_=$ARGV[1];
my $dow;
if(/^Su(?:n(?:days?)?)?$/io){           $dow=7;
}elsif(/^M(?:on(?:days?)?)?$/io){       $dow=1;
}elsif(/^Tu(?:esdays?)?$/io){           $dow=2;
}elsif(/^W(?:ed(?:nesdays?)?)?$/io){    $dow=3;
}elsif(/^Th(?:ursdays?)?$/io){      $dow=4;
}elsif(/^F(?:ri(?:days?)?)?$/io){       $dow=5;
}elsif(/^Sa(?:t(?:urdays?)?)?$/io){ $dow=6;
}else{
     &usage;
};

my ($year,$month,$day) = Today();

if($n ne 'l'){
     my $day2=(Nth_Weekday_of_Month_Year($year,$month,$dow,$n))[2];
     printf(
             "%04d-%02d-%02d\n",
             ($year,$month,$day2)
         ) if defined($day2) && $day2 >= $day;
     undef $day2;

     while(1){
         ++$month;
         if($month>12){
             $month=1;
             exit(0) if ++$year > 9999;
         };
         $day=(Nth_Weekday_of_Month_Year($year,$month,$dow,$n))[2];
         printf("%04d-%02d-%02d\n",$year,$month,$day) if defined($day);
     };
}else{
     my $day2=(Nth_Weekday_of_Month_Year($year,$month,$dow,5))[2];
     $day2=(Nth_Weekday_of_Month_Year($year,$month,$dow,4))[2]
         if !defined($day2);
     printf(
             "%04d-%02d-%02d\n",
             ($year,$month,$day2)
         ) if $day2 >= $day;
     undef $day2;

     while(1){
         ++$month;
         if($month>12){
             $month=1;
             exit(0) if ++$year > 9999;
         };
         $day=(Nth_Weekday_of_Month_Year($year,$month,$dow,5))[2];
         $day=(Nth_Weekday_of_Month_Year($year,$month,$dow,4))[2]
             if !defined($day);
         printf("%04d-%02d-%02d\n",$year,$month,$day);
     };
};
$

> From: "Rick Moen" <rick at linuxmafia.com>
> Subject: Re: [sf-lug] [SF-LUG Meets This Sunday 2020.01.02 @ 11:00am]
> Date: Sat, 22 Feb 2020 13:48:43 -0800

> Quoting maestro (maestro415 at gmail.com):
>
>> As someone so accurately brought to my attention...
>> The *ACTUAL DATE OF THE MEETING IS 2020.02.02*
>> Which is *SUNDAY*...
>> Maestro wrote 2020.01.02
>>
>> I will now report for caning.
>
> Some day, when you get tired of making this elementary mistake, you are
> invited to remember the advice of checking all even day/date
> combinations using /usr/bin/cal .
>
> Do so, and you'll never make that mistake again.
>
> Or, in the alternative, if you're still a fan of committing inadvertent
> comedy, keep ignoring that (oft-given) bit of advice.




More information about the sf-lug mailing list