in reply to DateTime parsing and midnight

I wouldn't lump the two together. One is a point in time, easiest modelled as DateTime instance. The other is a duration with a (fixed) start and endpoint or with a fixed start point and a length given in (say) minutes.

As the two are different, use different parsers.

Replies are listed 'Best First'.
Re^2: DateTime parsing and midnight
by pokki (Monk) on Nov 11, 2010 at 14:07 UTC

    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).

      Yes. That is a point in time. But the other string is a duration, as it is meant for the whole day, isn't it?

      In any way, as you seem to want the two to be treated differently, you will have to do so.

        I finally got what you meant, sorry. I never thought of all-day events as having a duration, despite their name; on calendar applications they are usually marked once for the day, not as having a duration of 24 hours. The use case is more like "Foo's birthday" than "It will be Foo's birthday for 24 hours today", if you get my meaning.

        It all probably means I'll have to distinguish them by hand after all, before giving them to DateTime::Format::whatever.

        I was hoping there would be some way to recognize a DateTime object created with no time from a DateTime object created with 0:00 as the time. Well, if there ain't, there ain't.

        Thank you for your input!