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
first
Update end time by Duration field and you will see "hh:mm" format
first

Issue fork smart_date-3184158

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ruslan Piskarov created an issue. See original summary.

Ruslan Piskarov’s picture

Status: Active » Needs review
mandclu’s picture

I'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?

Ruslan Piskarov’s picture

@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">

first

mandclu’s picture

Status: Needs review » Needs work

I 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.

hangoverocks’s picture

I 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.

Krys15’s picture

I 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.

matt_paz’s picture

JayVGee’s picture

Hi, 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?

mandclu’s picture

it makes smart_date un-useable with core datetime_range fields if there is a requirement for seconds

Can you clarify what you mean? In the previous sentence you mention that you don't need seconds.

Is there a way to get this accepted as a patch?

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.

ckng’s picture

Priority: Normal » Major
FileSize
21.37 KB

Run 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.

widget error

mandclu’s picture

Here'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.

  • mandclu committed 903a1c6 on 3.4.x
    Issue #3184158 by Ruslan Piskarov, mandclu, ckng: The issues with...
mandclu’s picture

Status: Needs review » Fixed

Merged 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.

Status: Fixed » Closed (fixed)

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