Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^6: Date::Manip Sunday Holidays

by SBECK (Hermit)
on Nov 29, 2015 at 03:49 UTC ( #1148794=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^7: Date::Manip Sunday Holidays
by SBECK (Hermit) on Dec 01, 2015 at 03:20 UTC
    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).
Re^7: Date::Manip Sunday Holidays
by SBECK (Hermit) on Dec 01, 2015 at 17:40 UTC

    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.

        I'll put it on my todo list. It's not a bad idea, and it wouldn't be too hard to implement.
      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.

        Sorry... I do almost nothing on windows and don't have any idea how the flow from CPAN to PPM works. You'd be better off referring to an ActiveState group. Or there's docs for how to create your own from CPAN IIRC (I believe I did that years ago).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-08-17 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (176 votes). Check out past polls.

    Notices?