
package JK::Misc;

use strict;
use Sys::Syslog;

my @EXPORT = qw/verbose debug slowerr/;

sub verbose {
        my $msg = join('', @_);

        warn "$msg\n" if $::opt{f};
        syslog( 'info', $msg );
}

sub debug {
    verbose(@_) if $::opt{D};
}

sub slowerr {
    verbose(@_);   
    sleep 5;
    exit 1;
}

sub days {
    my $month = shift || warn "days: no month supplied\n";
    my $year  = shift || warn "days: no year supplied\n";

    my $f = ( $year % 4 ) ? 28 : 29;
    my %months = ( 0 => 31, 1  => $f, 2  => 31,
                   3 => 30, 4  => 31, 5  => 30,
                   6 => 31, 7  => 31, 8  => 30,
                   9 => 31, 10 => 30, 11 => 31 );

    return $months{$month};
}


sub import {
    my $pkg = shift;
    my $caller = caller;

    for my $f ( @EXPORT ){
        no strict;
        *{$caller . '::' . $f} = $pkg->can($f);
    }
}

1;
