[sf-lug] Got meeting (up)dates? (web page updating of upcoming meeting dates)

Michael Paoli Michael.Paoli at cal.berkeley.edu
Tue Feb 5 22:33:40 PST 2013


Well, with cron and some suitable tools, schedule of upcoming meeting
date(s) can be automagically updated on web page(s).

This topic/subject/discussion has come up before[1][2].
I also include example use[3] and example code[4] further below.

references/excerpts(slightly redacted)/footnotes/examples:
1. https://groups.google.com/forum/#!msg/berkeleylug/PPemp9zv_Jk/yHNW0B5zlD8J
2.
> From: jim <jim at well.com>
> Subject: Re: [sf-lug] www.sf-lug.org & sf-lug.org - not looking so  
> good on The Internet
> Date: Tue, 05 Feb 2013 19:41:29 -0800

>     I might be willing if <redacted> allowed
> <recated> PHP language, which does the date updates for
> the SF-LUG.com site, but that it doesn't
3.
$ ./upcoming_meetings
usage: ./upcoming_meetings: {1st,2nd,3rd,[45]th,last}  
{Sun,Mon,Tues,Wednes,Thurs,Fri,Satur}day
$ { ./upcoming_meetings 1st Sun | head -n 12
> ./upcoming_meetings 3rd Mon | head -n 12
> } | grep '^2013-' | sort
2013-02-18
2013-03-03
2013-03-18
2013-04-07
2013-04-15
2013-05-05
2013-05-20
2013-06-02
2013-06-17
2013-07-07
2013-07-15
2013-08-04
2013-08-19
2013-09-01
2013-09-16
2013-10-06
2013-10-21
2013-11-03
2013-11-18
2013-12-01
2013-12-16
4.
$ expand -t 4 < 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);
     };
};
$





More information about the sf-lug mailing list