At present, day values in the backend represents:

0 sunday AM (first value)
1 sunday PM (second value)
2 monday AM (first value)
3 monday PM (second value)
...

Proposal is to extend the backend to provide an extra column: daydelta and convert values to:

day daydelta represents
0 0 1st slot for sunday
0 1 2nd slot for sunday
0 2 3rd slot for sunday
1 0 1st slot for monday
2 0 1st slot for tuesday
2 1 2nd slot for tuesday

as shown, day is converted to a standard 0..6 and daydelta extends the model to allow more than two slots per day.

Related to #1710258: More than 2 Time Blocks Per Day: upgrade to 21, 28... hours per week

See #1913292: [META] Untangle office_hours for reference.

Comments

johnv’s picture

Status: Postponed » Active

Perhaps it is not necessary to change the scheme. We can use the field 'delta' and set the subfield 'day' to the day number, like this:

delta day represents
0 0 1st slot for sunday
1 0 2nd slot for sunday
2 0 3rd slot for sunday
3 1 1st slot for monday
4 2 1st slot for tuesday
5 2 2nd slot for tuesday

We need to be careful with existing data, though.

johnv’s picture

Status: Active » Needs work

ITMT, I've implemented #1710258: More than 2 Time Blocks Per Day: upgrade to 21, 28... hours per week
After saving the data, the column 'day' does not contain the day-index any more (0,1,2,3,..,13).
It only contains the daynumber *2 : 0,2,4,6,8,10,12 .

It takes an upgrade_N hook to change this in all existing fields, an change code accordingly.

johnv’s picture

Status: Needs work » Fixed

This is fixed using the existing 'day' column.

An update function for the database storage is added here (since hook_field_load() and hook_field_presave() are not invoked when showing the default value): #1964274: Default value not set after wednesday
There is a follow-up issue regarding the javascript widget: #1945230: Javascript for 'N time blocks per day' is not complete

Thanks jonhattan, for the ideas &patches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.