in reply to Date Handling in Perl

If you are not using any of the Perl modules, you will be better off writing your own tailored to your requirements.
how is the best way to handle end-of-month/beginning-of-new-month changes, such as when $currentDay - 1 = 0 (the first of the month) because sometimes you then want it to = 30 and sometimes = 31 (or 28/29 for March 1st).
I'd done something similar in the past. I had written my own lastDayofMonth routine that also checked leap year. This is because we know in advance all possible lastDayOfMonth values
$lastDay = lastDayOfMonth($month); #returns a number indicating last d +ay ... sub lastDayOfMonth { my $month=shift; <sanity check here> return 29 if($month==2 and isLeapYear($currYear)); <and so on> }

Replies are listed 'Best First'.
Re^2: Date Handling in Perl
by Anonymous Monk on Jul 11, 2012 at 17:16 UTC

    Most of the other posts here are using Unix timestamps to do the date arithmetic, and it is a good idea for this particular case (especially when Perl comes with the functions needed for it). It is not a good idea to write the millionth instance of manual date arithmetic code in existence, when the vast majority of them are riddled with bugs. (See: recent outages involving 29 February)

    (I generally only trust well-known modules or an SQL database if I need to do date arithmetic)