Is it possible to force users to pick only one date and a start and end time? All our events take place on one day only but I don't want to make users pick the same date again for the To date just so they can pick an end time. Thanks!

Comments

Jo_’s picture

subscribing

penguin25’s picture

StatusFileSize
new4.18 KB

I wanted a feature like this as well, so I set about modifying the source code to achieve it. Attached is a patch for date-6.x-2.3 of what I've managed to do so far.

I don't consider this patch to be a complete, full solution. Please read all of the following points before applying the patch:

1) It only changes the user interface. At the database level, the start and end times are both stored with the single date specified by the user. This maintains compatability with things like the Calendar module.

2) If you specify an end time that is earlier than the start time, then the end date is set to be the day after the start date (this effectively allows for the end time being after midnight).

3) Any exisiting "end dates" will be lost if you edit them after applying this patch. The time part of the end date will be preserved, but the date part will be set to either the start date, or start date + 1, as appropriate. You won't be able to get the original end date back.

4) The patch changes the behaviour of the Date module globally - after applying the patch, you'll always be presented with just date, start time and end time. It is not configurable on a per-content-type basis.

5) The patch only definitely works when choosing dates and times from a select list. I know it doesn't work with the date popup browser. Custom text formats are untested - it may or may not work with these.

6) The patch is not tested at all with repeating dates.

Comments/improvements are most welcome. I'm definitely interesting in fixing points 4, 5 and 6 in the list above, but I can't promise to do it immediately myself! All the code changes I've made are marked with a comment SHOW_TIME_ONLY_FOR_END_DATE, so it should be easy to spot them after applying the patch.

penguin25’s picture

StatusFileSize
new9.89 KB

Here's an updated patch that fixes point (4) above. When setting up a date field, you previously had "Never", "Required" and "Optional" as possible settings for the "To Date". With my updated patch, you now have "Required (time only)" and "Optional (time only)" as well. The "Time only" options effectively enable the patch.

It also occurs to me that I haven't tested the patch at all on a system that makes use of timezones (my site uses "No timezone conversion" for all its date fields). So, the full list of features untested with this patch is:

- Choosing dates/times from any widget other than a select list.
- Using repeating/multiple dates per node.
- Using timezones.

arlinsandbulte’s picture

Status: Active » Closed (duplicate)

This looks like a good start. And I think it is similar enough to #127200: Allow user to specify duration (relative) or end time (absolute) to be marked as a duplicate.

I took all the work done by penguin25 and put it into #127200: Allow user to specify duration (relative) or end time (absolute)