On all my content types any field that is a Date (ISO format) when I save the date time the time always rounds up or down to the nearest 5 min increment. The fields are all textfields no popups. I haven't seen any settings where a time increment is set. Any advice?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Category: bug » support
Status: Active » Fixed

The increment is controlled in the field settings. There is a collapsed fieldset called advanced settings that you can open up to see what you can control.

mikeg333’s picture

Category: support » bug
Status: Fixed » Active

I think this is a bug not a support request. If I change the date field to a select list or popup I have the option of a time increment for minutes in the advanced settings. If I change it to a textfield there is no time increment in the settings but it is still incrementing the time I enter to the nearest 5 min mark.

mikeg333’s picture

If I add "date_text" to the array in line 297 of date_admin.inc I'm now able to see an increment option which after setting fixes my issue.

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

There should be no way to create a text date that has a 5 minute increment. How did that field get created in the first place?

KarenS’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I never got a response to my request for more information, so I'm assuming it is no longer an issue or the reporter doesn't care about this any more.

SKap’s picture

The field is just a standard date field with the textfield widget. If you enter a specific time - I tried 05:38, for example - upon saving, it changes to 05:30 or 05:45. Mikeg333 is correct though, if you change to the select list or popup widget, you have the option of choosing how this works. I see this as a bug, personally.

sjs’s picture

I encountered this bug too, although for me it was 15min, not 5min. The fix suggested in #3 works for me too, although in 7.x-2.3 it is line 316.

I think this bug might be due to a default 15 minute increment set in function date_field_widget_info().

kking’s picture

Status: Closed (cannot reproduce) » Active

I'm also having this issue but on seconds, not minutes. I'm trying to save a time/date as a UNIX timestamp and its rounding to the nearest 15 seconds

Text input field. Data attributes to collect: all fields.

2012-04-25 17:30:08 => 1335389415
2012-04-25 17:30:15 => 1335389415
2012-04-25 17:30:22 => 1335389415

2012-04-25 17:30:23 => 1335389430
2012-04-25 17:30:30 => 1335389430
2012-04-25 17:30:37 => 1335389430

sender’s picture

I can confirm this bug. Textfield widget is applying increments, but has no UI element to control this. The select widget does, as indicated, and this setting will be used by the textfield widget.

It's kind of a big deal, b/c while adding this field and keeping all default values, one ends up with a situation that behaves unpredictable.

lucor’s picture

I have the same issue. Version 7.x-2.5 on unix timestamp with minute granularity.
Textfield widget apply increments, if I use select list only the following values are avalaible: 00, 15, 30, 45.
I've unable to find a way to modify these settings with the UI.

ioannis.cherouvim’s picture

I confirm this on 7.x-2.5 with:
- Field: Date
- Widget: Text field
- Collect: Year Month Day Hour Minute Second

powery’s picture

I have the same issue. How to fix it?

DevElCuy’s picture

I confirm this bug. The date you input is being rounded to the nearest quarter hour.

The funny thing here is that if you set a granularity down till seconds, they are not rounded, just the minutes are being rounded.

DevElCuy’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Priority: Critical » Normal

EDITED:
Just tested again and can confirm that seconds are being rounded too, both minutes and seconds are being rounded to the closest quarter. I have tested with normal date fields using text field widget.

And just noticed that the "Select list" widget has minutes and seconds in quarters. So perhaps the round function is being called in the text field widget, when it should not be the case.

DevElCuy’s picture

Version: 7.x-2.x-dev » 7.x-2.5
Priority: Normal » Critical

Confirmed in stable version, this bug is critical.

DevElCuy’s picture

Version: 7.x-2.x-dev » 7.x-2.5
Priority: Normal » Critical
FileSize
934 bytes

Here is a patch for current stable release. If you already have a field, then follow this instructions to fix the issue:

- Switch your date field to "Select list" widget, to make the option "Time increments" available in your field settings.
- Set "Time increments" to "1 minute", it works for seconds too (should be one setting for second and another for minutes though)
- Save
- Switch your field widget back to "Text field"

NOTE: Attached patch will affect new fields only.

DevElCuy’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
826 bytes

Attached patch against 2.x-dev

Status: Needs review » Needs work

The last submitted patch, date-increment-1355256-2.patch, failed testing.

barraponto’s picture

I guess this approach avoids the issues that breaks the tests...

barraponto’s picture

Status: Needs work » Needs review

Go bot!

DevElCuy’s picture

Status: Needs review » Reviewed & tested by the community

Works like a charm!

DevElCuy’s picture

Title: date field minutes rounding after update/save » date field minutes and seconds rounding after update/save
Issue tags: +dlatino
KarenS’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.26 KB

Actually the patch needs a couple things. It changes the default increment for Date Popup widgets to 1, which is wrong, and it needs to include an update hook to fix the increment values for existing fields.

So the updated patch would be:

KarenS’s picture

Status: Needs review » Fixed

Oops, that patch was a little off, the basic default should be 15, then just reset the value for date_text.

http://drupalcode.org/project/date.git/commit/3eb62b6
http://drupalcode.org/project/date.git/commit/89dd330

Mark Theunissen’s picture

When is the next stable release due? This bug is huge - in our system nodes are imported programmatically, and every time someone opens the node/edit form and saves it, through the admin interface, any data in the date fields is destroyed by being rounded off. We're still in development, thank goodness, but this could potentially hose someone's data and a stable release should be a priority.

barraponto’s picture

This bug report is already critical, so let's ask for a new release and help with any possible release blocker. @Karen?

Status: Fixed » Closed (fixed)

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

ambientdrup’s picture

This patch is not working for me. I applied the patch via #24 and I have pop up calendar as the widget. The times still only increment by quarters. In other words I can't put in 5:16 p.m. It defaults to 5:15 p.m.

So does this patch work?

-Trevor

ambientdrup’s picture

Ok I see this only works with text field widget. Can we make this patch work with pop up calendar widget as well?

-Trevor

ambientdrup’s picture

Actually after testing this, the patch fails. When I switched to text field widget I then entered 5:12 p.m. as my time. That worked. However when I save the node the value that gets inserted and saved into the node (and db) is 5:15 p.m.:

Feb 18 2010 - 5:15pm

So the data is not saving in 1 increments even with the text field.

-Trevor

ambientdrup’s picture

One additional note/finding here. This patch did not work until I ran a db update. I checked my status report and the Database update script was showing red. I proceeded to run the db update and it updated the Date module to implement this increment change to "1". So I'd suggest that we add to the patch documentation that a db update is necessary before it actually works.

Also is there any possibility of making this work with the Date pop up widget?

-Trevor

DevElCuy’s picture

Version: 7.x-2.x-dev » 7.x-2.6

@ambientdrup, this issue has been resolved and released in version 7.x-2.6, you don't need the patch.

ambientdrup’s picture

Ok great. But does this patch only fix the text field? Does it also allow for minute incrementing using the pop up calendar widget? I still cannot get that to work using the patch.

-Trevor

ambientdrup’s picture

I can confirm the patch and update to 2.6 works and solves the increment issue. Just make sure to also configure the date field to use 1 min increments (under advanced config tab on the field).

Best-

Trevor

arlinsandbulte’s picture

@ambientdrup
what are your date field granularity settings?
I think it defaults to 15min granularity, which it looks like you are seeing.

ambientdrup’s picture

Yep you're absolutely right! I noticed that and changed it to 1 min.

It's working now! Awesome.

-Trevor

MD3’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I'm fearing reopening this, but I am experiencing the exact same issue.

Date 7.x-2.6
Drupal 7.24
ECK 7.x-2.0-rc2

Created a custom entity only to find the exact same issue as previously listed above: no way to change the default increment except to change the widget type. Why is the text field rounding? That's a pretty exact form of entry that one is entering.

MD3’s picture

I need to write a patch, but the issue is line 295 in date.field.inc where it uses the default settings.

frob’s picture

A work around for this issue is to set the date field to use select lists and then you will be able to change the date rounding options. After you set the increment back to 1 then you will be able to change it back to text field.

barraponto’s picture

Status: Active » Needs review
FileSize
767 bytes

This should fix it for good.

Status: Needs review » Needs work
DevElCuy’s picture

Status: Needs work » Reviewed & tested by the community

Great work!

rooby’s picture

Status: Reviewed & tested by the community » Needs work

I assume those test failures will need to be fixed.

rooby’s picture

It's also worth noting that while this fixes the problem for fields created after this patch is applied, it doesn't fix ones that were created before that and are still at the 15 minute increment.

If we want to fix those we should do another update function like the one in #23.

Status: Needs work » Needs review

Status: Needs review » Needs work
Romash’s picture

Status: Needs work » Needs review
FileSize
1.77 KB

Please review.

Status: Needs review » Needs work

The last submitted patch, 47: date-set_default_increment_value-47.patch, failed testing.

andreyks’s picture

Assigned: Unassigned » andreyks

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 47: date-set_default_increment_value-47.patch, failed testing.

katannshaw’s picture

@frob: Thank you. Your workaround on #39 worked for me.

marcvangend’s picture

I ran into the same problem. Since my field definitions were already exported to features, it was very easy to look up the date field instance in the .features.field_instance.inc file, change the line 'increment' => 15, to 'increment' => 1, and to a feature revert. While this is a pretty easy workaround, we still need a proper fix.

kevinus’s picture

I found same advanced setting for "Time increments" with next steps: 1, 5, 10, 15, 30 (default is 15). You searched this setting?




marcvangend’s picture

@kevinus: You have chosen the "popup calendar" widget. In that case the time increment is visible on the form. This issue is about the "textfield" widget. If you choose the textfield widget, the time increment setting disappears from the settings form, but the setting itself remains stored in the database and starts messing with your form input.

jgullstr’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Assigned: andreyks » Unassigned
Related issues: +#1549834: Dates input using Text fields are improperly rounded
FileSize
815 bytes

The commits listed in #24 would've solved this, but the default increment for date_text fields is put at the wrong level in the widget info array. Attached patch should put the setting in its right place, and update existing instances to an increment of 1 minute.

NancyDru’s picture

#56 works for me.

Ronino’s picture

#56 works great, thanks!

NancyDru’s picture

Status: Needs review » Reviewed & tested by the community
jiv_e’s picture

Patch #56 fixes the issue. I haven't tested for regressions.

  • podarok committed 3f2c698 on 7.x-2.x authored by jgullstr
    Issue #1355256 by develCuy, barraponto, KarenS, jgullstr, Romash: date...
podarok’s picture

Status: Reviewed & tested by the community » Fixed

#56 merged. Thanks

Status: Fixed » Closed (fixed)

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

aviddv1’s picture

I was able to solve this issue by temporarily changing to the Calendar Widget, adjusting the increment to 1 Minute, then changing back to a Text Field.