Howdy,

I'm integrating duration objects into an app I'm building, but have a bit of a problem using DateTime::Duration objects. The problem is this:

Say that a user selects a duration of "2 hours" for the duration in a Web form and saves it. The next time the user accesses that Web form, it won't say that the duration is "2 hours", but "120 minutes." This is inconsistent with what the user put in and how s/he thinks about it.

Now, I recognize that most users will be able to glance at something like that and see that some simple multiplication has been done. But I pity the user who enters a duration of "23 hours 59 minutes", because the next time they see the form, it will read, "1439 minutes". ETOOMUCHMATH!

Of course I understand that DateTime::Duration normalizes dates and times in order to correctly perform date math; however, it's annoying that there's no way to recover the actual arguments to new() or settings added via add(). In my mind, a DateTime::Duration object would always give me back the dates and times I gave to it rather than some simplification of it, but then it would only use the simplifications for date math (in deltas, I guess).

It may be too late to break compatibility ($du->hours currently returns 0 for "23 hours 59 seconds"), but if there was perhaps a way to get at the settings as they were specified, rather than how they will be used for date math, it will very much make things simpler for anyone who needs to manage a duration presentation widget.

The normalization stuff in DateTime::Format::Duration gets us part of the way there, but not quite, as if I say, "23 hours, 90 minutes", it will return "24 hours 29 minutes", which is not quite the same as what was initially specified.

At any rate, does this make sense to folks? If so, I'd be willing to hack something into DateTime::Duration to support this. Comments?

Thanks,

David

Reply via email to