Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Calculating latest 'Sunday' date on the first of the month

by roboticus (Chancellor)
on Sep 06, 2010 at 10:26 UTC ( [id://859037]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Calculating latest 'Sunday' date on the first of the month
in thread Calculating latest 'Sunday' date on the first of the month

Cicatrix:

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-25 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found