When a custom date format is defined with hook_date_fomats() and hook_date_format_types(), the information is saved to the date_formats and date_format_types. However, the corresponding system variables are not written to the variables table, so that when content_format is called, the date is not formatted with the desired format. The only time these variables are saved is when the form is submitted at admin/settings/date-time/formats. So in other words, if I want my custom formats that I've defined in my hooks to actually work, I have to go to admin/settings/date-time/formats and save the form.

I've looked through the code in date_api, and date_api_date_formats_form() is only place where date format variables are written to the variables table. Is there another way I'm missing to update the variables table?

Thanks,

Comments

JayKandari’s picture

Version: 6.x-2.7 » 7.x-2.10
Component: Date API » Code
Category: Support request » Bug report
Priority: Normal » Major
Issue summary: View changes

Can still reproduce this issue in 7.x-2.10 version.

I followed following steps in vanilla drupal with date module & date API enabled.

* Added field to a content type
* goto manage display
* Change date field format to custom,
* provide a custom date format eg: "d-m-y"
* click update & save content type.
* reopen date field format settings. Custom format field is empty.

Bonus, When you view a content with this settings. following warning is issued & date field isn't shown.

Notice: Undefined index: custom_date_format in date_formatter_format() (line 447 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.module).
Notice: Undefined index: formatted_timezone in theme_date_display_combination() (line 139 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).
Notice: Undefined index: formatted_time in theme_date_display_combination() (line 145 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).
Notice: Undefined index: formatted_time in theme_date_display_combination() (line 147 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).
DamienMcKenna’s picture

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