Created
January 13, 2014 14:04
-
-
Save marcusx/8400834 to your computer and use it in GitHub Desktop.
How to define date formats in a Drupal modules as a features export is only exporting half of the information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_date_formats(). | |
* | |
*/ | |
function my_module_date_formats() { | |
return array( | |
array( | |
'type' => 'my_module_year_only', | |
'format' => 'Y', | |
// This format is used for german and english. | |
// You need to separate this in most real life cases. | |
// The same format for two languages makes sense if to countries use the same format. | |
// e.g.: Austria and Germany; or Germany and Swiss | |
'locales' => array('de', 'en'), | |
), | |
array( | |
'type' => 'my_module_short', | |
'format' => 'd.m.Y', | |
'locales' => array('de', 'en'), | |
), | |
array( | |
'type' => 'my_module_medium', | |
'format' => 'D, d.m.Y', | |
'locales' => array('de', 'en'), | |
), | |
array( | |
'type' => 'my_module_month_only_long', | |
'format' => 'F', | |
'locales' => array('de', 'en'), | |
), | |
); | |
} | |
/** | |
* Implements hook_date_format_types(). | |
* | |
* Setting up some additional date types. | |
*/ | |
function my_module_date_format_types() { | |
// Define the date format types. | |
return array( | |
'my_module_year_only' => t('My Module year only'), | |
'my_module_short' => t('My Module short'), | |
'my_module_medium' => t('My Module medium'), | |
'my_module_month_only_long' => t('My Module month only long'), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment