Hi Monks,

I have a problem with the DateTime::Precise module. I have created the object with the following parameters.

  • Year -> 2006
  • Month -> 01 (Jan)
  • Date -> 31

  • The problem i am facing here is, when i increment the month by 1, it increments the date by 31 days and so it gets the date 2/31. But which is not a valid date. So, perl compensates by converting the days over into the next month. So 2/31 becomes 3/3.

    I have put this piece of code in another script which processes the records from the text file. I am facing this problem only when create the object from the January month having the date > 29.

    Can any one tell me how to get the correct month value when i do inc_month from the January object (having the $date >29 )?

    I can put a if condition to check the january objects.But, I am still trying to solve it through the module's methods.

    Have any of you faced this problem ? Any help would be highly appreciated.

    Thanks for your valuable time.

    Regards,
    S.Venni Rajan.
    "A Flair For Excellence."
                     BK Systems.


    In reply to How to get the correct incremented month through DateTime::Precise ? by vennirajan

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.