in reply to Re^5: Finding End of Month's date
in thread Finding End of Month's date
Trying on for size is a figure or speech for “now see how that looks”. I never golf.
Also, please look at a module before decrying it for inflexibility.
print $date->strftime( '%e' ); # it's there if you think you need it
By truncation I was referring the fact that the calculation starts at the beginning of the month rather than from “now”. Without your explanation, I'd've expected your snippet to produce June 15 when given May 16 as a start date. It's not obvious why it produces May 31 instead.
Or did you think the well known formula that checks the remainers of division of the year by 4, 100 and 400 got the edge cases right? ;-)
I know it doesn't, no need for the smiley. That's why I asked the question in the first place. I'd never attempt to do any date math on my own unless I'm setting out to write a date math library. Otherwise, there's just way too many gotchas to hang yourself with in that area. And when I pick a date math library, I usually stick to DateTime because I know there was (and is) a large and painstaking effort to get every last possible edge case right, and because the API is terrifically slick.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Finding End of Month's date
by Anonymous Monk on Jan 04, 2005 at 09:36 UTC | |
by Aristotle (Chancellor) on Jan 04, 2005 at 19:09 UTC | |
by Anonymous Monk on Jan 05, 2005 at 10:48 UTC |