I had an issue in which scheduler was always saving my dates at midnight (00:00). I traced this to be an input format related problem.

The first input format I used was: "m/d/Y h:i a" and executing this code would always return midnight:

$node = node_load(arg(1));
print format_date($node->publish_on);

When I switched the format to "m/d/Y H:i", the module began behaving correctly.

(Using date popup).

CommentFileSizeAuthor
#6 date-642018-6.patch544 bytesslip
#6 scheduler-642018-6.patch4.39 KBslip

Comments

kmonty’s picture

To be clear, this was the format on admin/settings/scheduler

eric-alexander schaefer’s picture

I checked it and you are right. Date popup does not handle the format correctly. E.g. it uses AM and PM if 'a' is configured (should be 'a' => am+pm, 'A' => AM+PM). It does not use the configured space between the minute and AM/PM. Either because of these two problems or for another reason it returns 0 minutes and 0 hours (=> midnight).
I will not bother filing an issue since the last issue I filed for the date popup module did not even receive an answer. I will just extend the format description at admin/settings/scheduler...

Thanks for reporting, but I am afraid you will have to live with H:i.

eric-alexander schaefer’s picture

Status: Active » Fixed
kmonty’s picture

Title: Scheduler does not properly function if you use AM/PM in your date format » Date popup breaks if you use AM/PM in your date format
Project: Scheduler » Date
Version: 6.x-1.6 » 6.x-2.4
Component: Code » Date Popup
Status: Fixed » Active

Thanks Eric. I am moving this to the date popup issue queue since it is definitely a bug that should be looked at.

slip’s picture

The date format setting at admin/settings/scheduler seems to need to be set perfectly to work with date_popup.

Works:
Y-m-d h:i:sA

Doesn't work:
Y-m-d h:i:s A

That one space seems to cause all sorts of problems, which seems a little crazy. If anybody wants to verify that'd be nice, but I definitely just had to remove the space and everything works... So if this is true the help text commit in #3 should be modified and maybe the date module needs to be a little more flexible or scheduler needs to do something different.

Got the idea from:

/**
 * Allowable time formats.
 */
function date_popup_time_formats($with_seconds = FALSE) {
  return array(
    'H:i:s',
    'h:i:sA',
    );
}
slip’s picture

Status: Needs review » Active
StatusFileSize
new4.39 KB
new544 bytes

So I've attached a patch that removes spaces from time formats so date.module reads them correctly. This would make a nice addition to date_popup.module in my opinion and it would help people avoid the pain I've experienced with the scheduler module :)

I've also included a rough patch to scheduler which makes it force valid time formats based on date_popup_time_formats() (but I need to know if this function actually exists to return the only possible valid formats which the calendar recognizes). This patch also allows the user to not use Date Popup with scheduler if both are enabled, which is another feature I think it'd be nice to have.

slip’s picture

Title: Date popup breaks if you use AM/PM in your date format » Date popup breaks if you use a space before AM/PM in your date format
Status: Active » Needs review
karens’s picture

Status: Active » Fixed

Close, but not quite right. Wiping out all spaces breaks things if you have spaces elsewhere in the date format. I committed a modified patch. Thanks!

function timepicker_format_replacements() {
  return array(
    'G' => 'H',
    'g' => 'h',
    'a' => 'A',
    ' a' => 'A',
    ' A' => 'A',   
    );
}
karens’s picture

Your scheduler patch needs to go in that queue.

slip’s picture

Thanks KarenS! I wasn't sure if I had it quite right so I'm glad you were able to improve it.

FYI: I created an issue for the scheduler module soon after I commented here. That patch was committed a few months ago.

Status: Fixed » Closed (fixed)

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