CCK time

lenkkivihko - June 22, 2007 - 20:03

How to implement measurement of duration with CCK?

Current situation

I have a site for sport exercises. Duration of exercise is measured in minutes. Seconds are measured in decimals. Challenge is that a minute is 60 seconds, not 100 seconds. This makes the input difficult.

Ideal situation

Time is inputed in minutes and seconds.

Issue

How to implement this?

Is the only solution to add a minutes and seconds filed to database. Then convert the current decimal based minute duration to those fields. Any "good" solutions for this?

Calculated field

NancyDru - June 22, 2007 - 23:03

Use the calculated field module and divide the seconds by 60.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

CCK duration

thomie - June 25, 2007 - 16:37

Hi lenkkivihko,
if you (or others) are interested in a module for recording 'durations', you can send me a message. I needed the same thing, and build a cck duration field type recently. You can select years/months/days/hours/minutes/seconds from a granularity box, and the data is stored in ISO format for duration. For example P1Y2M3DT4H5M6.78S would be 1 year, 2 months, 3 days, 4 hours, 5 minutes and 6.78 seconds. But any of these could be left blank, so years is for example not required as in date module. Note that the number of seconds can be a decimal, the other elements are integers. A duration field is optionally stored as seconds as well, which can be used for computations. For displaying: either the above ISO format, the number of seconds, or HH:MM:SS for time durations can be used.

CCK duration field

alan426 - November 20, 2007 - 04:19

I could really use something like that. Will you post it, or maybe send me a copy?

thanks thomie - he sent me a

mdowsett - April 3, 2008 - 03:26

thanks thomie - he sent me a copy and it worked perfect.

Duration module

jpetso - May 21, 2008 - 08:08

I wrote a Duration module - Drupal 6 only (unless someone else backports it to Drupal 5) - that module might be sufficient for this use case, and hopefully others as well :)

 
 

Drupal is a registered trademark of Dries Buytaert.