1. Go to admin/config/content/scheduler
  2. Set the following options:
    • Date format: "d-m-Y"
    • Field type: "Standard text field"
    • Date only: not checked

These settings are accepted when the form is submitted, but it should actually fail, since if no time part is supplied in the date format, the user should enable the 'date only' option and provide a default time, so Scheduler knows at which time the content should be scheduled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pfrenssen’s picture

Status: Needs review » Needs work

The last submitted patch, 1: 2143061-1-date_format_without_time-test_only.patch, failed testing.

pfrenssen’s picture

Status: Needs work » Needs review
jonathan1055’s picture

It is not obvious to me that this should be an error. Before we had the default time functionality a format such as d-m-Y was acceptable. The user entered the date, and there was an implicit default time of 00:00 on that day. It still works ok like that now.

If the admin wants to specify a time other than 00:00 then they can, but they should not be forced to tick the option. I suppose using the date-only option does give the benefit that the description displays the default time, but that is the only difference as far as user experience is concerned.

Was there a particular test scenario which caused you to want this, or was it just a separate idea?
Jonathan

pfrenssen’s picture

Status: Needs review » Closed (works as designed)

I thought it was a bug, but apparently it is a feature :)

jonathan1055’s picture

Category: Bug report » Task
Status: Closed (works as designed) » Needs review

I'd be ok if you wanted to implement this, you didn't need to close it yet ;-) The change does have the advantage that the users then see the time that will be used.

I did not actually look at your patch, but I have done now and at first glance you've done quite a few useful changes. Marking as 'needs review' and I will look at in detail tomorrow.

Jonathan

jonathan1055’s picture

Title: Throw validation error when entering a date format without a time, and not choosing the 'date only' option » Only allow date format with no time if the 'date only' option is ticked
Status: Needs review » Needs work
FileSize
52.19 KB

Having considered the coding in the patch, I think that this is worth doing. The benefit is that the user is told the default time in the text beneath the entry box. Also you have re-factored scheduler_admin_submit() to use internal functions, and removed the call to the date_popup function. The messages are better formed too.

The patch does not apply to the current git .module or .test, due to the recent patches committed, but I tested the code manually and it works as expected. Just one point - coder review does not like the call to drupal_set_message(implode(' ', $messages))

Hopefully you can find a neat way to avoid that, as it is really helpful now that coder review gives a clean pass of .module.

Jonathan

jonathan1055’s picture

Title: Only allow date format with no time if the 'date only' option is ticked » The 'date only' option must be turned on for a format with no time element

Making the title into a positive statement

jonathan1055’s picture

How about the simple, but clear (and coder-review clean):

  if (empty($time_only_format)) {
    drupal_set_message(t('The date part of the Scheduler format is %date_part. There is no time part', array('%date_part' => $date_only_format)));
  }
  else {
    drupal_set_message(t('The date part of the Scheduler format is %date_part and the time part is %time_part.', array('%date_part' => $date_only_format, '%time_part' => $time_only_format)));
  }
jonathan1055’s picture

The patch needed re-rolling as a lot of code has been changed since Nov 2013.

In .module I kept it the same except (a) $format was no longer used and the two lines had been merged into one when setting $time_format, so I replicated that, and (b) I incorporated my drupal_set_message suggestion from #9 to keep it coder-compliant.

For .test the change to $this->drupalCreateUser is not needed as we have already added the 'administer scheduler' permission since the original patch.

So, essentially the same patch. If you are OK with this it can be committed.

Jonathan

The last submitted patch, 10: 2143061-10-date_format_without_time_test_only.patch, failed testing.

jonathan1055’s picture

I have re-worked the existing tests into the new loop, first for textfield, then for date_popup. This is better (and hence safer) than directly setting the config variables, as we have found out before. Patch is against 1.2+11-dev

jonathan1055’s picture

FileSize
6.59 KB

Patch needed re-rolling, now against 7.x-1.2+15

pfrenssen’s picture

I already forgot about this one :) At my previous project this functionality was needed, they are already using this in production for many months.

Very good point to save the settings through the interface rather than manipulating the variables. This is a more true functional test. This looks pretty good to me.

Uploading the test only, this should fail.

Status: Needs review » Needs work

The last submitted patch, 14: 2143061_13_date_format_without_time-test_only.patch, failed testing.

pfrenssen’s picture

Status: Needs work » Reviewed & tested by the community

Test only patch failed, perfect, good to go!

pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

  • pfrenssen committed 9f4e3ab on 7.x-1.x
    Issue #2143061 by jonathan1055, pfrenssen: The 'date only' option must...

Status: Fixed » Closed (fixed)

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