I'm planning on using DateTime::Format::Flexible or DateTime::Format::Natural to parse datetime strings. The problem is that the string to be parsed may or may not contain a time component, e.g. "2010-11-11 Thu" is valid, as is "2010-11-11 Thu 22:00".

How do I differentiate between a DateTime object that was built from a string without a time component, and one which was built from, say, "2010-11-11 Thu 0:00", since both would have the same time component?

(This is a calendaring type application, so "no time component" is to be interpreted as "all day", not just as "user forgot to set date so we'll treat it as an error" or "use a default". It's also built from an existing format which I can't extend to manually indicate "all day" type timestamps.)

Update I may not have made myself clear, but the time in the string is not a duration, it's part of a timestamp, e.g. "Meeting <2010-11-11 Thu 13:00>" means that a meeting is scheduled for November 11 at 13:00 (or 1 PM).

In reply to DateTime parsing and midnight by pokki

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.