Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Date::Manip Sunday Holidays

by u65 (Chaplain)
on Nov 28, 2015 at 20:42 UTC ( #1148779=note: print w/replies, xml ) Need Help??


in reply to Re^4: Date::Manip Sunday Holidays
in thread Date::Manip Sunday Holidays

Excellent, the solution right from the author. Thanks, SBECK!

Replies are listed 'Best First'.
Re^6: Date::Manip Sunday Holidays
by SBECK (Chaplain) on Nov 29, 2015 at 03:49 UTC

    Unfortunately, it appears that I didn't get the right answer. Going back and rereading it (more carefully this time around), the desired date of New Years is:

    1/1 if 1/1 is Mon-Fri OR Sat 1/2 if 1/1 is Sun

    That's much more complicated. I found something that I thought would work...

    1*1:0:1:0:0:0*NBD,BD1,IBD,FD1 = New Year's Day (Saturday) 1*1:0:1:0:0:0*NBD,BD1,NBD,FD2 = New Year's Day (Sunday observed Mon +day) 1*1:0:1:0:0:0*IBD = New Year's Day (real)

    but it is failing on some years. I actually think it might be a bug. I'll check into it tomorrow.

    I have definitely decided that I need to add a couple more modifiers similar to IBD and NBD which will check if it is a given day of the week. That would make this much simpler. I hadn't been aware of the complexity of the holiday definition used here.

      There was definitely a bug. I fixed it today and it will be in the next release (originally scheduled for tomorrow 12/1, but it will probably get pushed back a day or two to allow me to complete the work to get this working).

      In the next release (6.52 which should be released tomorrow after a bit more testing), you will be able to define New Years the way you are asking in a couple of ways:

      # Saturday 1*1:0:1:0:0:0*NBD,BD1,IBD,FD1 = New Year's Day # Sunday (observed Monday) 1*1:0:1:0:0:0*NBD,BD1,NBD,FD2 = New Year's Day # M-F 1*1:0:1:0:0:0*IBD = New Year's Day

      or

      # Saturday 1*1:0:1:0:0:0*IW6 = New Year's Day # Sunday (observed Monday) 1*1:0:1:0:0:0*IW7,FD1 = New Year's Day # M-F 1*1:0:1:0:0:0*IBD = New Year's Day

      It's important to name the holiday the same for all definitions.

        ...And since I have the ear of "The Man", just a thought: the ability to input a hash or array of holidays would be powerful. Maybe through the constructor or a routine parameter? Say for example, if I want to keep a table of holidays in my sql db, then they could be maintained by a user through a web interface instead of an admin in a config file. Then I could query the db and input those days into the date object. Not that I spend waaaaay too much time thinking about holidays or anything.

        Unless of course this functionality already exists and I missed it somewhere in the documentation dispite studying it for hours. If that's the case, then nevermind.

        Simply beautiful.

        Do you know how many YEARS this has plagued me? Now I can set it once and never touch it again. Since every single date routine I do involves holiday handling, this is the primary reason I use this module for everything. Thank you!

        I was able to update the package on my Linux boxes and it's working perfectly. However, my Win2012 64bit ActiveState v5.20 ppm is only showing the latest available for Date::Manip is v6.50. Repository is set to http://ppm4.activestate.com/MSWin32-x64/5.20/2000/package.db.gz and showing a last check datetime of 12/2/2015 @ 13:11. Looking at the ActiveState, it's showing latest release is 6.52, but only 6.51 in the table.

        Any idea how long until it's ready for ppm?

        Sorry, I feel like I finally got my red rider bb gun for Christmas.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1148779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-05-14 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?