Hi,

I ran into a problem with a program I was working on today and
couldn't figure out what the correct way to solve it with DateTime
was.  I ended up brute-forcing it, but I'd like to know the right way
for future work.

The gist of what I wanted to do is this:

- Take a DT object which has been truncated to day.
- Take a string like "10:30 AM".
- Set the time on the DT object according to that string.

I tried making a Strptime object with pattern '%I %p' but that seems
to just return undef when I try to parse these times.  It looks like
maybe I want a DateTime::Incomplete, but it's not clear how to make
one from a string.  And it also looks like maybe I want a
DateTime::Duration since I want to add it to my DT object, but again,
how to make one from a string?

I ended up parsing the string myself and calling set methods on the
DT, but that seems pretty lame with all of these classes available.

Any pointers, including to FAQs or archived posts, would be appreciated.

- Perrin

Reply via email to