(Using: Drupal 6.5, CCK 6.x-2.0-rc10, Duration 6.x-1.0-rc2)

The title above may be unclear, so let me give an example of the problem as I perceive it.

I have configured a duration field with the largest metric being 'HOURS' and the smallest metric being 'MINUTES'.

If I enter in a node a duration with the value 1 for 'hours' and '65' for minutes, the node will display 1h 65m (value in dabatase table: PT1H65M), where it should in my mind display 2h 5m (PT2H5M) as there cannot be more than 60 minutes in an hour (the "carry-over point" of the 'minutes' is exceeded). This could be done by adding a check on the values of the fields on validation of the node as follows:

* if largest metric = minutes, check that seconds are < 60, or else recalculate the duration accordingly,

* if largest metric = hours, check the values of both minutes and seconds < 60 respectively, or else recalculate accordingly.

* if largest metric = days, check that hours < 24, minutes < 60, seconds < 60 respectively, or else recalculate accordingly.

* if largest metric = weeks, check that days < 7, etc...

A warning message could be added on validation to alert the user to the fact that his input has been corrected.

I would personally favour a check+recalculation method for dealing with this, but implementing a check that does not validate the node until the smallest metrics have been corrected to ensure that their values do not exceed their carry-over point could be another solution.

What do you think ?

Comments

jpetso’s picture

Yes, might be worthwhile for the user interface too. The API part of the module already has a function to do that, so maybe a checkbox for enabling that functionality in the widget settings makes sense too. I don't want to force this onto sites without giving an option to turn it off, because some "overflows" are not necessarily accurate / reliably reversible (e.g. without a given start date, we don't know how many days a month has).

Easy coding work, things may get done a lot faster if someone provides a patch.

yuit’s picture

Good point about making it optional. As for helping out with this, unfortunately I am afraid I am better at asking questions than providing php code. Believe me, you would not want to see any php output from me ;-)

jpetso’s picture

I believe you :P
Let's see when I can spare a little time to do this. (Help from other people still appreciated!)