Welcome to the Monastery | |
PerlMonks |
Re^3: Calculating latest 'Sunday' date on the first of the monthby roboticus (Chancellor) |
on Sep 06, 2010 at 10:26 UTC ( [id://859037]=note: print w/replies, xml ) | Need Help?? |
The code ikegami gave you, and the result you reported are what I'd expect from the specifications you gave in your original post. So if you're getting something incorrect, you need to be more clear in specifying the problem. Also, you report the problem several days after accepting the answer provided. I suspect that you didn't adequately test the code before reporting success. Normally, you want to test code against all the different types of input cases that will be encountered. So rather than setting $d = DateTime->today() only, you'd initialize $d to various dates, and compare the results of the code with the date you'd expect. I suggest you try Test::More and related packages (if you don't use them now), and use them to build tests for code before accepting it. You'll find that the tests, if written well, can also serve as documentation for your code, as it will show future programmers what behaviour to expect for the unusual cases. ...roboticus
In Section
Seekers of Perl Wisdom
|
|