Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

barbie (2653)

barbie
  reversethis-{ku. ... m} {ta} {eibrab}
http://barbie.missbarbell.co.uk/

Leader of Birmingham.pm [pm.org] and a CPAN author [cpan.org]. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [yapc-surveys.org] and the QA Hackathon [qa-hackathon.org] websites. Also the current caretaker for the CPAN Testers websites and data stores.

If you really want to find out more, buy me a Guinness ;)

Links:
Memoirs of a Roadie [missbarbell.co.uk]
[pm.org]
CPAN Testers Reports [cpantesters.org]
YAPC Conference Surveys [yapc-surveys.org]
QA Hackathon [qa-hackathon.org]

Journal of barbie (2653)

Friday November 18, 2005
03:15 PM

Dreadlock Holiday

[ #27643 ]

I had an email recently regarding Calendar::List. It suggested adding some support for holidays. I hadn't thought about that before, but it seems a good idea. I was thinking about the best way to add this support. The nice way would be to enable support for the Holiday::* modules, which would help to improve those authors Kwalitee rating. However, as Richard Clamp points out, not all APIs are consistent. Also what if there isn't a holiday module for a particular country, or a user wants to be able past a standard list to the module. So to keep things simple I've added the 'holidays => \@holidays' option to the configuration hash.

  my @holidays = are_holidays(2005);
  my %hash = { exclude => { 'holidays' = \@holidays } };
  my @list = calendar_list('DD-MM-YYYY', \%hash);

The only awkward bit is the are_holidays() function, which would the rely on being able to generate the holiday dates in the format required for calendar_list(). But then with an example patch to Date::Holidays::UK, you could do the following:

  use Date::Holidays::UK;

  sub are_holidays {
    my $year = shift;
    my @dates;
    for my $date (are_uk_holidays($year)) {
      my @elms = split(/-/,$date);
      push @dates sprintf "%02d-%02d-%04d", $elms[2], $elms[1], $elms[0];
    }

    return @dates;
  }

In the meantime Calendar-List-0.17.tar.gz is now on its way to CPAN :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • not all APIs are consistent

    They're not, but they should be.

    Jonas already did a nice job creating Date::Holidays and convincing some people to change their Holidays::* API, myself included.

    You could probably talk one or two more into it too ;-)

    And after that... WORLD DOMINATION!!!

    MUAHAHAHAHAHA

    (oh... was it still on?)