in reply to Date Range Parsing
I would suggest using Date::Calc to verify that $date is really a valid date, and I'm sure there's TIMTOWTDI.
here's a sample I whomped up off the top of my head:
Note that there's a lot of improvement to be wrung from this -- the regexp to split the date and the concatenation to reform it could be removed by using just $this_year and $this_month and $this_day, but this might require some other adjustments to your code. update : There's a function in Date::Calc called Add_Delta_YMD which does pretty much the same thing.while ($date <=$end_date) { . . . (manipulate data here) . . . ($this_year, $this_month, $this_day) = ($date =~/(\d{4})(\d(2})(\d{2}) +/) if (!checkdate ($this_year, $this_month, $this_day) { # a new month dawns $this_day=1; if ($this_month ==12) {#did december just pass $this_year++; $this_month=0; } $this_month++; #add one to the month. $date = $this_year . $this_month . $this_day; } }
|
|---|