I've been looking for something to create a very user-friendly time field in CCK so content types can specify opening and closing times etc. Date module does it, but I don't want to have to specify DD/MM/YYYY, so I've created a decimal field with select list and allowed values of:

0|Midnight
0.5|12:30am
1|1:00am
1.5|1:30am
2|2:00am
2.5|2:30am
3|3:00am
3.5|3:30am
4|4:00am
4.5|4:30am
5|5:00am
5.5|5:30am
6|6:00am
6.5|6:30am
7|7:00am
7.5|7:30am
8|8:00am
8.5|8:30am
9|9:00am
9.5|9:30am
10|10:00am
10.5|10:30am
11|11:00am
11.5|11:30am
12|Midday
12.5|12:30pm
13|1:00pm
13.5|1:30pm
14|2:00pm
14.5|2:30pm
15|3:00pm
15.5|3:30pm
16|4:00pm
16.5|4:30pm
17|5:00pm
17.5|5:30pm
18|6:00pm
18.5|6:30pm
19|7:00pm
19.5|7:30pm
20|8:00pm
20.5|8:30pm
21|9:00pm
21.5|9:30pm
22|10:00pm
22.5|10:30pm
23|11:00pm
23.5|11:30pm
24|Midnight

I can then use the computed field to calculate the difference between start and end times etc

Could this be turned into a slider, ideally with even more increments (possibly every 15/10/5/minute of the day?)

If it's possible I'd be happy to consider sponsoring development to implement this feature

Thanks

Stu

Comments

StuartDH’s picture

There's an old D5 CCK Time module http://drupal.org/project/cck_time that's soon to be updated to D6 that might make a good combo

Stu

skilip’s picture

Stu,

This should be quite simple I guess. Currently the slider only support integers, but you could use a range of 0 - 240. I will take a look at cck_time module asap.

Best, Philip

StuartDH’s picture

Thanks Philip, I got the slider working after your recent beta2 update. I tested a slider with min & max of 0 & 288 to produce something equivalent to having a time input with 5 minute intervals for an entire day, and found it very easy, quick and accurate to specify a particular point. Thinking about it, decimal isn't strictly needed in the time scenario above as it could be solved with just a slight change to the calculation in the computed field.

However, it would be great to be able create labels for the individual slider points (similar to the select list above), with labels like 12:05pm for point 145 on the 0 to 288 time slider. This would mean that users could also build sliders with labels for height in feet and inches to set metric values, or slide days of the week, months of the year, have values 1,2,3 show as 100, 200, 300 etc so the user see text labels. but the info stores numerically

Stu

skilip’s picture

Status: Active » Postponed
Issue tags: +extending with text labels

Hey Stu,

I totally agree this would be a really nice feature. However, instead of adding the ability to define labels for numeric fields, I think it is better to create a slider widget for text fields. The field would then store string values directly, instead of numeric.

Probably it will take me several hours to build this feature. I will do this whenever I've got time for it. I'll let you know!

StuartDH’s picture

Hi Skilip,

Yep, I can see lots of uses for the text-only slider, but I think that labelled numeric fields would create lots of uses by storing the numeric part in the DB so you can then carry out calculations with computed fields etc. This would be similar to fivestar, where users could slide out different ratings for quality (text selection from very bad to very good), cost($,$$,$$$ etc), value (stars?) then total them all up at the bottom of the page to give an overall score

Lots of uses and a really nice way of getting visitors to interact with websites, rather than the ugly old drop-down menus

Stu

skilip’s picture

You're right about this! It's indeed much more flexible to store the keys of the label array. The only problem then is the context. You wouldn't think of numeric input if you're planning to use the slider for strings. You'd more likely think of a option list I guess. But maybe if I promote it very specifically, this won't be a big issue.

skilip’s picture

Title: Decimals for time fields » Add a configuration option for defining the labels