Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When the end time field changed, a new value can be without seconds, and not possible to save a node because of the wrong format, and HTML 5 waits for "hh:mm:ss" format.
Steps to reproduce
Create a node with a start time like 11:12:33
Update end time by Duration field and you will see "hh:mm" format
Comment | File | Size | Author |
---|---|---|---|
#13 | smart_date-daterange_seconds-3184158-13.patch | 1.93 KB | mandclu |
Issue fork smart_date-3184158
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
Ruslan PiskarovReady for review https://git.drupalcode.org/issue/smart_date-3184158/-/compare/3184158-th....
Comment #4
mandclu CreditAttribution: mandclu at Northern Commerce commentedI'm not sure I understand what you're trying to do. Smart Date hides the seconds intentionally, since in a typical use cases they don't need to be specified, and they're also not shown or used in popular calendar applications. Why do you need them?
Comment #5
Ruslan Piskarov@mandclu, it isn't possible to save node because form validation doesn't allow. We need to add support for seconds or remove it totally. Right now the HTML has 'placeholder="hh:mm:ss"'. Sorry if not clear.
<input class="time-end form-time" data-drupal-selector="edit-field-when-0-end-value-time" title="Time (e.g. 01:17:17)" type="time" step="1" placeholder="hh:mm:ss" data-help="Enter the time using the format hh:mm:ss (e.g., 01:17:19)." id="edit-field-when-0-end-value-time" name="field_when[0][end_value][time]" value="15:00:00" size="12">
Comment #6
mandclu CreditAttribution: mandclu at Northern Commerce commentedI was finally able to reproduce this, by using the Smart Date widget with a core datetime range field. Additional steps to reproduce:
- Set default values for start and end to current date or some offset from the current time e.g. "+1 hour"
- After the form loads with seconds set, use the duration dropdown to cause the end date to be updated
- The end time will be formatted without seconds, which will trigger an error on submit
I've tended to be of the mindset that it would be better to omit the seconds, to align with how calendar apps from Google, Apple and others work. This is why I the modules sets the step to 60 seconds. I won't merge in a change that alters this, but I would consider a change that makes this setting of the step value conditional on the initial values of the seconds being zero.
Personally I would also prefer to see some kind of normalization of the default data to set the seconds to zero, but perhaps that should be a separate issue.
Comment #7
hangoverocks CreditAttribution: hangoverocks commentedI sidestepped this bug by using the Date Time hide Seconds module (https://www.drupal.org/project/datetimehideseconds), which, I believe, sets the seconds to 00 and hides the seconds field.
Comment #8
Krys15 CreditAttribution: Krys15 commentedI have a use case for seconds - i want to use smart date to use as a schedule at a radio station. The seconds will determine the start of a recording session - and needs to be seconds specific.
Comment #9
matt_paz CreditAttribution: matt_paz commentedAdding a related core issue that may be of interest ...
http://drupal.org/node/2699895
Comment #10
JayVGee CreditAttribution: JayVGee commentedHi, I have run into the same issue as Ruslan Piskarov. I dont need the seconds, however it makes smart_date un-useable with core datetime_range fields if there is a requirement for seconds. Is there a way to get this accepted as a patch?
Comment #11
mandclu CreditAttribution: mandclu at Northern Commerce commentedCan you clarify what you mean? In the previous sentence you mention that you don't need seconds.
I'm not likely to change the default widget to use seconds, since I prefer to keep it aligned with how popular calendar applications work, and they tend to omit seconds. Also, for a typical use case (scheduling meetings or events people will attend) even having to tab through the seconds is an unnecessary annoyance.
I'd be more likely approve a patch that adds a new widget for using seconds instead of adding it to the default widget.
In terms of dealing with issues of compatibility with core fields, I'd rather deal with any additional normalization that is needed to preserve the current UX.
Comment #12
ckngRun into this issue as well. Mark as Major since it breaks admin UI to create/edit node with the SmartDate field widgets. Tested this is happening to both SmartDate widgets.
Comment #13
mandclu CreditAttribution: mandclu at Northern Commerce commentedHere's a patch that should set the default seconds to zero when using the widgets with daterange fields. Let me know if this resolves your issue.
Comment #15
mandclu CreditAttribution: mandclu at Northern Commerce commentedMerged in the patch from #13 so it could be included in an upcoming beta release. Closing this issue but feel free to reopen (or better yet, open a child issue) if additional work is needed.