Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Date::Manip Sunday Holidays

by ksublondie (Friar)
on Nov 27, 2015 at 22:10 UTC ( [id://1148735]=perlquestion: print w/replies, xml ) Need Help??

ksublondie has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Date::Manip to determine the next business day, taking holidays into account. My problem is business days are M-F, but observed holidays are the following day (Monday) if the holiday is a Sunday, however, if holidays land on a Saturday, they are still observed on that day.

Following the documentation, I've tried in my holiday config file 1*1:0:1:0:0:0*NWD = New Years Day, but it lists BOTH Saturday and Sunday New Year days on the following Monday. I've also tried 1*1:0:2:0:0:0*WD2 = New Years Day, but it always picks the Monday of the week of Jan 2.

Is there a way I can dynamically generate the correct observed holidays? I'm currently hard-coding these Sunday holidays every few years which is a perfect environment for screwing it up.

CLARIFICATION: Holidays are to be observed on their usual date unless it falls on a Sunday. In this case, the holiday is observed the following Monday. In addition, Saturdays are never "business" days.

EDIT: Monday Jan 2 = New Years Day (observed) is essentially what I need, but that syntax doesn't work.

Replies are listed 'Best First'.
Re: Date::Manip Sunday Holidays
by u65 (Chaplain) on Nov 27, 2015 at 22:33 UTC

    Off the top of my head that doesn't right, at least as far as US federal holidays. I believe those that fall on Saturday are observed on the preceding Friday (update: New Year's Day may be the exception).

    Update: I think the first solution is correct: the first business day will fall on Tuesday when 1 January falls on Saturday, Sunday, or Monday.

      https://www.frbservices.org/holidayschedules/:

      "For holidays falling on Saturday, Federal Reserve Banks and Branches will be open the preceding Friday. For holidays falling on Sunday, all Federal Reserve Banks and Branches will be closed the following Monday. "

        Oops, my bad. Looks like a bug to me.

Re: Date::Manip Sunday Holidays
by ambrus (Abbot) on Nov 28, 2015 at 20:02 UTC

    May I ask what country this is for?

    Sadly for Hungary, it's impossible to know the business days in advance, because the government decides about them only during the automn of the previous year. You can mostly guess them, but there's a little bit of freedom. So you need frequently updated tables.

      US

      Most federal holidays are the same each year, unless a unique one-time holiday is declared (eg. someone important dies, etc). However, I'm specifically determining holidays for the Federal Reserve which doesn't typically observe any more than the same 10 holidays each year. The difference is subtle, yet still exists.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1148735]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found