For a site in French language (use of locale module) I haven't found how I can get the following display (Vendredi 6 Janvier 2009) for the "day title" of the page when I click on a day within a calendar in a block. I've attached both a capture of the date/time administration settings and the page output of the current day from my calendar.
Apart of this request, I would mention that I haven't found any right template for the usual french ouput of a long date, in the administration settings, that is for today : Vendredi 6 Janvier 2009, without any comma.

I've just upgraded my site from 1.x to 2.x.It is working fine. Thank you a lot for such a great work !

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thePanz’s picture

Version: 5.x-2.0-rc5 » 6.x-2.x-dev
Component: Code » User interface

Is this issue still active? I've got the same problem (with latest 2.x-dev Calendar and Date modules)

Regards

thePanz’s picture

Title: Day output format for a day page display with calendar module » Hardcoded day/month/week output format for theme_date_nav_title()
Component: User interface » Code
Category: support » bug

I've done further investigations..

I found that "function theme_date_nav_title()" (inside date/theme/theme.inc file) hard-coded the outputed date format for day/week/month titles.
Maybe the right way to retrieve the right format is to have an option in the calendar view, or something that can be used with i18n (I mean different day title for different country conventions).

For now I re-hardcoded my setting and solved my issue, but I know that it's the worst way to go.. :)

KarenS’s picture

Now that we have our new locale-friendly system for managing date formats we probably should use them in the titles, so I agree this is needed.

Unfortunately I don't really have time to work on it right now, but maybe some will make a patch to let you identify which format should be used for the titles (our new date format system will then automatically handle the locale-switching).

thePanz’s picture

KarenS: if you can point me to the "new locale-friendly system for managing date formats" I can try to provide a patch. I only managed to get the "long" format (that should be locale-safe), but I can't remove the "hour:minutes" parts.

Is in Date_API something usefull to remove a format sub-part?
Thank you

Regards

marcushenningsen’s picture

subscribing

gagarine’s picture

tracking

harrrrrrr’s picture

@ thePanz:

You can copy the code in your template.php & change the beginning of the function name: "theme_..." into "YOUR_THEME_NAME_...".

Drupal will use the function in template.php, so no changing needed in the module.

cledman’s picture

hi,... it didn´t work to me.
my template´s name is CES, as you can see here:
; $Id: ces.info,v 1.5 2007/07/01 23:27:32 goba Exp $
name = CES

so, I copy the theme_date_nav_title from date module and past that into /themes/ces/template.php and renamed that to
CES_date_nav_title.

nothing happens. I try just to put some ECHO to display anything, but nothing happens. Could you help me?
My callendar displays a wrong month, so I want to fix that in that function.
thanks

harrrrrrr’s picture

did you clear cache ?

Cyberwolf’s picture

Subscribing

carolalind’s picture

cledman

(My themes name: xxx)
I copied the function theme_date_nav_title from the date/theme/theme.inc into sites/default/themes/xxx/template.php. I changed the name of the funtion to xxx_date_nav_title and modified the formats on the differant dates and saved. Worked like a charm!!!

I have been strugeling with this for a long time and this was so easy when you know what to do! Now I'm going to change the date strings from other modules like this as well, hope it works as easily!

DanilaD’s picture

Subscribing - I have the same problem in Russian language.

Vincent Groen’s picture

Also subscribing - same problem for Dutch language

s427’s picture

Subscribing.

I've applied a patch to template.php to get a french format for the date (as explained in #411828: Bad date format in Week and Day Calendar view in French ), but my problem is that my site is available in five languages (fr/en/de/it/es), so this solution only works for languages that share the same date format as french...

asiby’s picture

Hi folks,

Just in case you are still having trouble using the theme override function, here is how to do it ... simple name the function phptemplate_date_nav_title instead of your_theme_name_date_nav_title.

Personally, I have hard-coded two if..else conditions and it did the trick.

/**
 * Theme the calendar title
 */
function phptemplate_date_nav_title($granularity, $view, $link = FALSE, $format = NULL) {
  global $language;
  switch ($granularity) {
    case 'year':
      $title = $view->date_info->year;
      $date_arg = $view->date_info->year;
      break;
    case 'month':
      $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'F Y' : 'F');
      $title = date_format_date($view->date_info->min_date, 'custom', $format);
      $date_arg = $view->date_info->year .'-'. date_pad($view->date_info->month);
      break;
    case 'day':
      if($language->language == "fr"){
          $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'l, j F Y' : 'l, j F');
      } else {
        $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'l, F j Y' : 'l, F j');
      }
      $title = "###" . date_format_date($view->date_info->min_date, 'custom', $format);
      $date_arg = $view->date_info->year .'-'. date_pad($view->date_info->month) .'-'. date_pad($view->date_info->day);
      break;
    case 'week':
      if($language->language == "fr"){
          $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'j F Y' : 'j F');
      } else {
        $format = !empty($format) ? $format : (empty($view->date_info->mini) ? 'F j Y' : 'F j');
      }
      
      $title = t('Week of @date', array('@date' => date_format_date($view->date_info->min_date, 'custom', $format)));
        $date_arg = $view->date_info->year .'-W'. date_pad($view->date_info->week);
        break;
  }
  if (!empty($view->date_info->mini) || $link) {
      // Month navigation titles are used as links in the mini view.
    $attributes = array('title' => t('View full page month'));
      $url = date_real_url($view, $granularity, $date_arg, TRUE);
    return l($title, $url, array('attributes' => $attributes));
  }
  else {
    return $title;
  }  
}
dhendriks’s picture

subscribing

nlambert’s picture

subscribing

MegaChriz’s picture

Instead of override the theme function theme_date_nav_title() you can also add a preprocess function in your module or template. An example for the date_navigation preprocess function:

<?php
/**
 * Preprocess date navigation
 * @param array $vars
 * @return void
 */
function xxx_preprocess_date_navigation(&$vars) {
  $view = $vars['view'];

  $link = FALSE;
  // Month navigation titles are used as links in the block view.
  if (!empty($view->date_info->block) && $view->date_info->granularity == 'month') {
    $link = TRUE;
  }

  // Set Dutch format for days and weeks
  $format = NULL;
  switch ($view->date_info->granularity) {
    case 'day':
      $format = 'l j F Y';
      break;
    case 'week':
      $format = 'j F Y';
      break;
  }
  $vars['nav_title'] = theme('date_nav_title', $view->date_info->granularity, $view, $link, $format);
}
?>
madmanmax’s picture

Nice one, I knew there had to be an easier way :)

mediameriquat’s picture

Subscribing.

I would like to apply this solution to the new "Date pager" functionality... This is more a Views 3.x issue than a Date issue now. Not sure if I should move this thread.

See webchick comment here:
http://www.drupalgardens.com/content/date-browser-format-views

Date Browser was a way to page back and forth between results by date, rather than by page number. I say "was" because this feature was recently removed from the Date module at http://drupal.org/node/1357362 in favour of the new "Date pager" capabilities.

I know code in #18 is pretty close, but I can't make it work in Drupal 7.

kristoferaberg’s picture

Thanks #11 worked for me, but the file has changed location now (Drupal 7.12, Date 7.x-2.2, Calendar 7.x-3.0, Views 7.x-3.3), as far as I can see, to: sites/all/modules/date/date_views/theme/theme.inc

mediameriquat’s picture

Thank you so much, #11 works like a charm in Drupal 7.

As long as a site is unilingual, this hack is fine. But what should we do in multilingual sites ?

Should this issue become a feature request rather than a bug report ?

alexanderpas’s picture

I suggest we split off a feature request to add a couple of date types (Year, Month, Week, Day) and use these date types in those area's where currently a hardcoded date type is used.

The benefit of this system is that we can customize the date format for those date types and can localize those date types where applicable.

hodota’s picture

I agree, many Japanese Drupal users are waiting localize functions at Calendar date display correctly.

We hope those functions will be fixed in future version, soon. thanks.

Cheers,

Kazu hodota

Grimreaper’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Active » Needs review
FileSize
3.49 KB

Hello,

Here is a patch for the 7.x version.

It adds two variable for the week format. Settable in admin/config/regional/date-time/date-views.

Thanks for the review.

Status: Needs review » Needs work

The last submitted patch, 25: date_views_week_format_355058-25.patch, failed testing.

Grimreaper’s picture

Grimreaper’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 27: date_views_week_format_355058-27.patch, failed testing.

izus’s picture

  1. +++ b/date_views/date_views.module
    @@ -1,8 +1,78 @@
    +
    +  $form['#submit'][] = 'date_views_settings_submit';
    +
    +  return system_settings_form($form);
    

    system_settings_form already saves the variables. So, you shouldn't need the Submit handler at all

  2. +++ b/date_views/theme/theme.inc
    @@ -179,11 +179,11 @@
    -      $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j, Y' : 'F j');
    +      $format = !empty($format) ? $format : (empty($date_info->mini) ?  variable_get('date_views_week_format_with_year', 'F j, Y') : variable_get('date_views_week_format_without_year', 'F j'));
    

    i suggest to have two variables at teh begining of the switch and use them form more redability.

    Alsowe shouldn't only focus on the 'week' case

about the patch it self, i think it doesn't apply because of a missing black line at the end

Grimreaper’s picture

Status: Needs work » Needs review
FileSize
4.95 KB

Thanks for the suggestions.

I am wondering if I should not implement a hook install and a hook update N to initialize the variables, to prevent the default value of the variable_get in the theme.inc ?

podarok’s picture

Status: Needs review » Needs work

#31 should provide hook_uninstall for removing all the variables from system_settings_form() https://api.drupal.org/api/drupal/modules!system!system.api.php/function...

Grimreaper’s picture

Status: Needs work » Needs review
FileSize
6.07 KB

Hello,

Now there is a hook_install and a hook_uninstall.

I wonder if the default values should be in a t() function or not ?

Thanks for the review.

Status: Needs review » Needs work

The last submitted patch, 33: date_views_week_format_355058-33.patch, failed testing.

Grimreaper’s picture

Status: Needs work » Needs review
FileSize
6.08 KB

Status: Needs review » Needs work

The last submitted patch, 35: date_views_week_format_355058-35.patch, failed testing.

podarok’s picture

I wonder if the default values should be in a t() function or not ?

nope, without t()

Grimreaper’s picture

Ok, thanks for your response.

The test failed, but I think the problem is not due to the patch because date views seems not to be tested and the patch don't affect the elements in error.

podarok’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: date_views_week_format_355058-35.patch, failed testing.

The last submitted patch, 35: date_views_week_format_355058-35.patch, failed testing.

podarok’s picture

The last submitted patch, 31: date_views_week_format_355058-31.patch, failed testing.

podarok’s picture

Title: Hardcoded day/month/week output format for theme_date_nav_title() » [Tests broken] Hardcoded day/month/week output format for theme_date_nav_title()

we should fix tests before commiting this

podarok’s picture

Status: Needs work » Postponed

possibly there is a bug due to 2013->2014 year on testing bot )))
#31 was green on 2013, but red on 2014
anyway - unrelated bug and should be fixed in folowup
postponing this

podarok’s picture

vijaycs85’s picture

Status: Postponed » Needs review
podarok’s picture

Title: [Tests broken] Hardcoded day/month/week output format for theme_date_nav_title() » Hardcoded day/month/week output format for theme_date_nav_title()
Status: Needs review » Reviewed & tested by the community
vijaycs85’s picture

vijaycs85’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, Committed c756e07 and pushed to 7.x-2.x.

Status: Fixed » Closed (fixed)

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

eliosh’s picture

Status: Closed (fixed) » Needs work

there's a typo in theme_date_nav_title.
It must be:

  $format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
  $format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j');

Actually, the variable name is wrong, because without "_" after $granularity.

Thanks a lot.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: date_views_week_format_355058-35.patch, failed testing.

prezaeis’s picture

hi everyone, on the month calendar i want to move the date of the current month from where it currently sits to somewhere else on the page. i want to place it as the main title of the page, i have been pulling my hair out for 2 days and cannot for the life of me figure this out.

anyone able to help me?

nasi’s picture

As pointed out in #52, there is an error in theme_date_nav_title, where the underscores are missing between $granularity and 'format_…". So the default format (l, F j, Y or l, Fj is being returned in all cases, regardless of the granularity required or the user specified settings.

So, for example, month view calendars have a l, F j, Y title rather than F Y.

#671068: Calendar title is always in day format

nasi’s picture

nasi’s picture

Apologies, just check the latest dev release and this bug has already been fixed.

Road Kill’s picture

Unfortunately even in the latest dev this problem is still around :(