Thread

  1. plperl functions -- can they call each other?

    Will Trillich <will@serensoft.com> — 2003-01-29T19:52:18Z

    create or replace function to_partial_ymd(int2,int2,int2)returns int4 as '
    my ($y,$m,$d) = @_;
    $m = 0 unless $y;
    $m = 0 unless 1 <= $m and $m <= 12;
    $d = 0 unless $m;
    $d = 0 unless (1 <= $d and
    	(
    		# 28 days valid for ANY month:
    		($d <= 28)
    		or
    		# 29 days valid if not february -- or in a leap year
    		($d <= 29 and ( $m != 2 or $y % 4 == 0 ))
    		or
    		# 30 days valid if not february
    		($d <= 30 and $m != 2)
    		or
    		# 31 days valid jan/mar/may/jul/aug/oct/dec
    		($d <= 31 and $m =~ /^(1|3|5|7|8|10|12)$/)
    	)
    );
    return ($y << 16) + ($m << 8) + ($d << 0);
    ' language 'plperl'; -- '
    
    sure would be nice to have such hefty day-of-month logic just
    ONCE, and be able to call it from other functions...
    
    is there still no way for one plperl function to call another plperl
    function? (i'm hoping that section 25.3.4 is out-of-date...)
    
    -- 
    There are 10 kinds of people:
    ones that get binary, and ones that don't.
     
    will@serensoft.com
    http://sourceforge.net/projects/newbiedoc -- we need your brain!
    http://www.dontUthink.com/ -- your brain needs us!
     
    Looking for a firewall? Do you think smoothwall sucks? You're
    probably right... Try the folks at http://clarkconnect.org/ !
    
    
  2. Re: plperl functions -- can they call each other?

    Jean-Luc Lachance <jllachan@nsd.ca> — 2003-01-29T20:50:46Z

    Another Y2K bug in the making...
    
    Leap year if:
    ((y % 4 == 0) and ( y % 100 != 0)) or ( y % 400 == 0)
    
    will trillich wrote:
    > 
    > create or replace function to_partial_ymd(int2,int2,int2)returns int4 as '
    > my ($y,$m,$d) = @_;
    > $m = 0 unless $y;
    > $m = 0 unless 1 <= $m and $m <= 12;
    > $d = 0 unless $m;
    > $d = 0 unless (1 <= $d and
    >         (
    >                 # 28 days valid for ANY month:
    >                 ($d <= 28)
    >                 or
    >                 # 29 days valid if not february -- or in a leap year
    >                 ($d <= 29 and ( $m != 2 or $y % 4 == 0 ))
    >                 or
    >                 # 30 days valid if not february
    >                 ($d <= 30 and $m != 2)
    >                 or
    >                 # 31 days valid jan/mar/may/jul/aug/oct/dec
    >                 ($d <= 31 and $m =~ /^(1|3|5|7|8|10|12)$/)
    >         )
    > );
    > return ($y << 16) + ($m << 8) + ($d << 0);
    > ' language 'plperl'; -- '
    > 
    > sure would be nice to have such hefty day-of-month logic just
    > ONCE, and be able to call it from other functions...
    > 
    > is there still no way for one plperl function to call another plperl
    > function? (i'm hoping that section 25.3.4 is out-of-date...)
    > 
    > --
    > There are 10 kinds of people:
    > ones that get binary, and ones that don't.
    > 
    > will@serensoft.com
    > http://sourceforge.net/projects/newbiedoc -- we need your brain!
    > http://www.dontUthink.com/ -- your brain needs us!
    > 
    > Looking for a firewall? Do you think smoothwall sucks? You're
    > probably right... Try the folks at http://clarkconnect.org/ !
    > 
    > ---------------------------(end of broadcast)---------------------------
    > TIP 4: Don't 'kill -9' the postmaster
    
    
  3. Re: plperl functions -- can they call each other?

    Will Trillich <will@serensoft.com> — 2003-01-31T23:21:30Z

    On Wed, Jan 29, 2003 at 03:50:46PM -0500, Jean-Luc Lachance wrote:
    > Another Y2K bug in the making...
    > 
    > Leap year if:
    > ((y % 4 == 0) and ( y % 100 != 0)) or ( y % 400 == 0)
    
    oh sure, if you subscribe to that nasty, tired, old, worn-out
    gregorian calendar prototype... :) [good eye.]
    
    [plperl CODE=snippet FEEDBACK=welcome]
    >       # 28 days valid for ANY month:
    >       ($d <= 28)
    >       or
    >       # 29 days ok if !feb -- or in a leap year
    >       ($d <= 29 and ( $m != 2 or $y % 4 == 0 ))
    >       or
    >       # 30 days good if not february
    >       ($d <= 30 and $m != 2)
    >       or
    >       # 31 days ok for jan/mar/may/jul/aug/oct/dec
    >       ($d <= 31 and $m =~ /^(1|3|5|7|8|10|12)$/)
    [/plperl]
    
    first discrepancy, since 1901, would be 29 feb 2100. (and the
    whole y%400 y!%100 y%4 paradigm will need revision anyway
    somewhere around 2800 or so, depending on your parameters).
    lifetime of this project is unlikely to be a decade, certainly
    not a century. not worth the excess computing cycles, methinks,
    certainly not for my situation.
    
    still, you win the prize for first eyeball. :)
    
    -- 
    There are 10 kinds of people:
    ones that get binary, and ones that don't.
     
    will@serensoft.com
    http://sourceforge.net/projects/newbiedoc -- we need your brain!
    http://www.dontUthink.com/ -- your brain needs us!
     
    Looking for a firewall? Do you think smoothwall sucks? You're
    probably right... Try the folks at http://clarkconnect.org/ !