medalto has asked for the wisdom of the Perl Monks concerning the following question:

i want to create a series of arrays of dates for the first 6 months of the year The output for march isnt correct . Anyone know why, and how to fix it ?
my $start="$y-$m-01";my $first="$y-$m-01"; my $datestr = UnixDate(ParseDate($start), " %b");my $last_day=ParseDat +e("last day in $datestr"); print "$first,$start,$end\n"; my @t_dates = &ParseRecur("0:0:0:1:0:0:0",$first,$start,$end); print "@t_dates"; print "\n------\n";
2011-01-01,2011-01-01,2011-01-31 2011010100:00:00 2011010200:00:00 2011010300:00:00 2011010400:00:00 20 +11010500:00:00 2011010600:00:00 2011010700:00:00 2011010800:00:00 201 +1010900:00:00 2011011000:00:00 2011011100:00:00 2011011200:00:00 2011 +011300:00:00 2011011400:00:00 2011011500:00:00 2011011600:00:00 20110 +11700:00:00 2011011800:00:00 2011011900:00:00 2011012000:00:00 201101 +2100:00:00 2011012200:00:00 2011012300:00:00 2011012400:00:00 2011012 +500:00:00 2011012600:00:00 2011012700:00:00 2011012800:00:00 20110129 +00:00:00 2011013000:00:00 2011013100:00:00 ------ 2011-02-01,2011-02-01,2011-02-28 2011020100:00:00 2011020200:00:00 2011020300:00:00 2011020400:00:00 20 +11020500:00:00 2011020600:00:00 2011020700:00:00 2011020800:00:00 201 +1020900:00:00 2011021000:00:00 2011021100:00:00 2011021200:00:00 2011 +021300:00:00 2011021400:00:00 2011021500:00:00 2011021600:00:00 20110 +21700:00:00 2011021800:00:00 2011021900:00:00 2011022000:00:00 201102 +2100:00:00 2011022200:00:00 2011022300:00:00 2011022400:00:00 2011022 +500:00:00 2011022600:00:00 2011022700:00:00 2011022800:00:00 ------ 2011-03-01,2011-03-01,2011-03-31 2011030100:00:00 2011030200:00:00 2011030300:00:00 2011030400:00:00 20 +11030500:00:00 2011030600:00:00 2011030700:00:00 2011030800:00:00 201 +1030900:00:00 2011031000:00:00 2011031100:00:00 2011031200:00:00 2011 +031300:00:00 2011031400:00:00 2011031500:00:00 2011031600:00:00 20110 +31700:00:00 2011031800:00:00 2011031900:00:00 2011032000:00:00 201103 +2100:00:00 2011032200:00:00 2011032300:00:00 2011032400:00:00 2011032 +500:00:00 2011032600:00:00 2011032700:00:00 2011032801:00:00 20110329 +01:00:00 2011033001:00:00 ------ 2011-04-01,2011-04-01,2011-04-30 2011040100:00:00 2011040200:00:00 2011040300:00:00 2011040400:00:00 20 +11040500:00:00 2011040600:00:00 2011040700:00:00 2011040800:00:00 201 +1040900:00:00 2011041000:00:00 2011041100:00:00 2011041200:00:00 2011 +041300:00:00 2011041400:00:00 2011041500:00:00 2011041600:00:00 20110 +41700:00:00 2011041800:00:00 2011041900:00:00 2011042000:00:00 201104 +2100:00:00 2011042200:00:00 2011042300:00:00 2011042400:00:00 2011042 +500:00:00 2011042600:00:00 2011042700:00:00 2011042800:00:00 20110429 +00:00:00 2011043000:00:00 ------ 2011-05-01,2011-05-01,2011-05-31 2011050100:00:00 2011050200:00:00 2011050300:00:00 2011050400:00:00 20 +11050500:00:00 2011050600:00:00 2011050700:00:00 2011050800:00:00 201 +1050900:00:00 2011051000:00:00 2011051100:00:00 2011051200:00:00 2011 +051300:00:00 2011051400:00:00 2011051500:00:00 2011051600:00:00 20110 +51700:00:00 2011051800:00:00 2011051900:00:00 2011052000:00:00 201105 +2100:00:00 2011052200:00:00 2011052300:00:00 2011052400:00:00 2011052 +500:00:00 2011052600:00:00 2011052700:00:00 2011052800:00:00 20110529 +00:00:00 2011053000:00:00 2011053100:00:00 ------ 2011-06-01,2011-06-01,2011-06-30 2011060100:00:00 2011060200:00:00 2011060300:00:00 2011060400:00:00 20 +11060500:00:00 2011060600:00:00 2011060700:00:00 2011060800:00:00 201 +1060900:00:00 2011061000:00:00 2011061100:00:00 2011061200:00:00 2011 +061300:00:00 2011061400:00:00 2011061500:00:00 2011061600:00:00 20110 +61700:00:00 2011061800:00:00 2011061900:00:00 2011062000:00:00 201106 +2100:00:00 2011062200:00:00 2011062300:00:00 2011062400:00:00 2011062 +500:00:00 2011062600:00:00 2011062700:00:00 2011062800:00:00 20110629 +00:00:00 2011063000:00:00 ------

Replies are listed 'Best First'.
Re: Date::Manip problem when creating arrays
by Corion (Patriarch) on Aug 01, 2011 at 21:11 UTC
Re: Date::Manip problem when creating arrays
by ww (Archbishop) on Aug 01, 2011 at 21:18 UTC
    That mass of output is truly mind-deadening...
    ...so I may have missed something.

    But it looks to me as though the last entry for March is
    2011033001:00:00 or, more readably: 2011-03-30 01:00:00.

    Is the way the month is shortened by 23 hours the problem you're asking about?
    Update: or 47 hours, depending on how you look at it -- carefully or carelessly. Mea culpa

    If so, sad to say, I see nothing obvious * in your code to explain why that's wrong and those other months I looked at appear to be correct.

    * OTOH, the mind rot incurred by reading the output (some judicious eliding, before you posted, would have helped) may be to blame for my ovesight.

      aplogies - its a balance between editing the output to highlight the problem, and enough of the output to show that there is a problem. All the output appears fine, except the last days of March
      2011032100:00:00 ..... 2011032600:00:00 2011032700:00:00 2011032801:00:00 2011032901:00:00 2011033001:00:00 it goes from 2011-03-27 00:00:00 to 2011-03-28 01:00:00 same on 29th and same on 30th and misses out completely 31st

        Have you read the documentation on Date::Manip::Recur? It explains how the recurrence pattern works. If you use it as you did, you get exact distances, and it seems that, somewhat naturally, Date::Manip declares a "day" to be "24 hours".

        It seems from the documentation that the following could work:

        0:0:0:1*0:0:0

        ... but to be sure, I recommend you actually read the documentation, now that you are aware of the fact that not all "days" are 24 hours long.