|Think about Loose Coupling|
DateTime parsing and midnightby pokki (Monk)
|on Nov 11, 2010 at 13:50 UTC||Need Help??|
pokki has asked for the
wisdom of the Perl Monks concerning the following question:
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).