I was just curious about all day events, I'm not sure if I'm missing something. Is it possible to just not show the time (12:00am-11:59pm) for an all day event?

I did research on this because I noticed when I switched to 12hr format there seemed to be a problem. I searched and learned that it was a bug in 5.x-1.x, so I switched over to the 5.x-2.x-dev to test it out.

I got to thinking why keep track of the hours at all for an all day event? I'm not sure what the ical standard is for handling this. It seems like you wouldn't need to worry about a start and end time at all but rather have a flag for "all day".

Anyways, if it's possible to simply hide the times on an event that is "12:00am-11:59pm" I'd like to know.. thanks. Also if I'd like to help where's the best place to start?

Eric

Comments

goose2000’s picture

Me too, I do not need those times showing up for all day events, clutter. And confuses people at first. I'm looking at it now...

John A

ecarter’s picture

After testing specific cases, I found that "all day" does appear on the calendar if you use 24hr format. However if I use 12hr format, then checking "All Day" at the top of a new content type seems to be only the current hour. In my case it shows:

TEST 12hr Format All Day
Start: 12:00 pm
End: 12:59 pm

Where if you have 24hr format selected, you see:

TEST 24hr Format All Day
all day

Eric

ecarter’s picture

After tinkering with this a bit, I think I found where the issue is. I'm a bit rusty with my javascript so maybe someone can chime in.

What I found was that the "End Date" is set to "12" for hour and "59" for minutes when "All Day" is selected in 12 hour mode.

Also, the hours go from "00" to "12" in 12 hour mode, presumably this should be 01-12.

Here's the code I found that generates the hours in the event module itself (event.module) on line 1478:

  if (variable_get('event_ampm', '0')) {
    $hour_format = t('g');
    for ($i = 0; $i <= 12; $i++) $hours[$i] = $i < 10 ? "0$i" : $i;
    $am_pms = array('am' => t('am'), 'pm' => t('pm'));
    if ($date['hour'] < 12) {
      $date['ampm'] = 'am';
    }
    else {
      $date['ampm'] = 'pm';
    }
    $date['hour'] = $date['hour'] % 12;
    if ($date['hour'] == 0) {
      $date['hour'] = 12;
    }
  }

So if we changed for ($i = 0; $i <= 12; $i++) to for ($i = 1; $i <= 12; $i++) then it will count from 1 through 12.

As for the all day module, I found that if I added:

    // are we using 12hr mode?
    if (variable_get('event_ampm', '0')) {
        drupal_add_js($path . '/event_all_day_12h.js');
    }
    else {
        // we are in 24h mode
        drupal_add_js($path . '/event_all_day.js');
    }

Then I could use different javascript files for the time notation. I tried working with it and changed the end time:

    ($("#edit-end-hour").val() == "11") &&
    ($("#edit-end-minute").val() == "59") &&

However, I couldn't quite figure out how to change the start_ampm and end_ampm with javascript as they had no CSS id's. Not sure where that's defined.

One other thing I've noticed in troubleshooting this is that when I select "12am" as the start time it is converted to "12pm". As a test, I created an event from 12am to 12:30am and it was created as 12pm through 12:30pm.

The next test, I created an event that started at 12am and ended at 1am. It created an event with just a single start time of 12pm. Same thing happened when ending an event at 3am.

The last test, I created an event from 1am through 3am and it was created successfully.

For what it's worth.
Eric

salvis’s picture

Thank you for your debugging work, Eric.

2.x-dev is still work in progress -- well, actually, it's sorta stuck while killes decides

  • which JS calendar to use and
  • whether to replace those obscure magic numbers/relations with additional flags in the database, namely for
    • "all day" aka "hide times",
    • "instantaneous events" aka "hide end date/time", and possibly
    • "adjust to user's timezone or leave as-is"

Once these questions are decided, Michelle's effort at http://drupal.org/node/147558 might get some new life and hopefully a decision in the end, and then your JS knowledge would be most appreciated to actually implement it. Until then...

ecarter’s picture

Hi, thanks Salvis. Well I'd be happy to help out where I can. I thought I'd try using 2.x-dev because of the issues I read concerning the 12hr thing on 1.x.

I did figure though whole thing out.. spent the day learning about JQuery used within Drupal. That's pretty cool stuff. Once observation I made, that may be helpful to others:

It's not clear but I don't think there's an easy way using the forms builder (includes/form.inc) to specify individual css ID or classes using the "radios" type where you pass in an array of radio button options. Instead, you'll have to use the individual value of each radio button.

I think this is part of the struggle Michelle was having in another thread I read where the suggested course of action was to make "00" and "23" be the defaults in javascript. It doesn't work because the drop downs should only be 1-12 for the 12 hour system. You cannot select "00" or "23".. in 2x-dev the 00 is there, but the upper limit is 12. If that makes any sense..

So, I had to modify the following line first to take out "00" in the event.module file ~ line 1481:

  if (variable_get('event_ampm', '0')) {
    $hour_format = t('g');
    //for ($i = 0; $i <= 12; $i++) $hours[$i] = $i < 10 ? "0$i" : $i;
    // changing this line so only 1-12 appear in 12hr format.. eric
    for ($i = 1; $i <= 12; $i++) $hours[$i] = $i < 10 ? "0$i" : $i;

then within event.module, I had to modify the following ~ line 2035:

    // We are using 12hr time format..
    if (variable_get('event_ampm', '0') == 1) {

      // Adjust 12am for Start Time to 00.. eric
      if (($form_values['start_ampm'] == 'am') &&
          ($form_values['start_hour'] == 12)) {
          $form_values['start_hour'] = 00;
      }

      // Adjust 12am for End Time to 00
      if (($form_values['end_ampm'] == 'am') &&
          ($form_values['end_hour'] == 12)) {
          $form_values['end_hour'] == 00;
      }

Then, within event.module around line 3052 I had to add the following:

            // let's try this 12 to 00 thing here? eric
            if ($node->start_ampm == 'am' && $node->start_hour == 12) {
                $node->start_hour = 00;
            }
            if ($node->end_ampm == 'am' && $node->end_hour == 12) {
                $node->end_hour = 00;
            }

That's all I changed within the event module. Now, on to the contrib/event_all_day module..
I changed the logic so I had a separate javascript file for 12hr vs 24hr.
(Around line 24..)

    $path = drupal_get_path('module', 'event_all_day');
    //drupal_add_js($path . '/event_all_day.js');
    //theme_add_style($path . '/event_all_day.css');

    // are we using 12hr mode?
    if (variable_get('event_ampm', '0')) {
        drupal_add_js($path . '/event_all_day_12h.js');
    }
    else {
        // we are in 24h mode
        drupal_add_js($path . '/event_all_day_24h.js');
    }

Then, I just kept hacking away at JQuery until I could figure out how to select the radio buttons without using a css ID or class.
I just modified two of the functions related to figuring out the event all day.. the following function will determine if people select an "all day" event manually.

function eventAllDayDetermine() {
  if (
    ($("#edit-end-hour").val() == "11") &&
    ($("#edit-end-minute").val() == "59") &&
    ($("#edit-start-hour").val() == "12") &&
    ($("#edit-start-minute").val() == "0") &&
    ($("#input:radio[@name='start_ampm']").val() == "am") &&
    ($("#input:radio[@name='end_ampm']").val() == "pm")) {
      EventAllDayYes();
      $("#edit-start-minute-all-day").attr("checked","true");
  }
}

Than, I updated the function that automagically changes the input fields for start and end times.

function EventAllDayYes() {

  $("#edit-end-hour").val(11);
  $("#edit-end-minute").val(59);
  $("#edit-start-hour").val(12);
  $("#edit-start-minute").val(0);

  $("input:radio[@name='start_ampm']")
    .filter("[@value='am']")
    .attr("checked",true);

  $("input:radio[@name='end_ampm']")
    .filter("[@value='pm']")
    .attr("checked",true);

  $("div.time").attr("style", "display: none;");
}

It seems to work alright so far, I know it's kinda cobbled together. There may be a more elegant solution.
Thanks for pointing me to the UI discussion, I'll follow up there. I'm new to all of this, just started working with Drupal in June. However I'm excited about the community and the flexibility of the software.

All the best,
Eric

salvis’s picture

Hi Eric,

I hope that killes (the maintainer of the Event module) will find time to make the necessary decisions and to provide the guidance as to in which direction he wants Events to evolve. Until then your efforts will probably be in vain, so please save some breath.

The preferred way to submit proposed changes is described in http://drupal.org/patch/create and http://drupal.org/patch/submit, and following that recipe will increase your chances for catching killes' attention.

Thanks in advance!
Hans

Anonymous’s picture

(subscribing)

jtjones23’s picture

subscribing

Anonymous’s picture

Status: Active » Fixed

There is a patch that does what you want (at least I think so) at http://drupal.org/node/199417

Anonymous’s picture

Status: Fixed » Closed (fixed)

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