#30 Add more date formats
This commit is contained in:
parent
da6c723830
commit
1a134d7319
1 changed files with 41 additions and 22 deletions
|
@ -228,12 +228,23 @@ class element extends \mod_customcert\element {
|
|||
* @return array the list of date formats
|
||||
*/
|
||||
public static function get_date_formats() {
|
||||
$dateformats = array();
|
||||
$dateformats[1] = 'January 1, 2000';
|
||||
$dateformats[2] = 'January 1st, 2000';
|
||||
$dateformats[3] = '1 January 2000';
|
||||
$dateformats[4] = 'January 2000';
|
||||
$dateformats[5] = get_string('userdateformat', 'customcertelement_date');
|
||||
$date = time();
|
||||
|
||||
$dateformats = array(
|
||||
'strftimedate' => userdate($date, get_string('strftimedate', 'langconfig')),
|
||||
'strftimedatefullshort' => userdate($date, get_string('strftimedatefullshort', 'langconfig')),
|
||||
'strftimedateshort' => userdate($date, get_string('strftimedateshort', 'langconfig')),
|
||||
'strftimedatetime' => userdate($date, get_string('strftimedatetime', 'langconfig')),
|
||||
'strftimedatetimeshort' => userdate($date, get_string('strftimedatetimeshort', 'langconfig')),
|
||||
'strftimedaydate' => userdate($date, get_string('strftimedaydate', 'langconfig')),
|
||||
'strftimedaydatetime' => userdate($date, get_string('strftimedaydatetime', 'langconfig')),
|
||||
'strftimedayshort' => userdate($date, get_string('strftimedayshort', 'langconfig')),
|
||||
'strftimedaytime' => userdate($date, get_string('strftimedaytime', 'langconfig')),
|
||||
'strftimemonthyear' => userdate($date, get_string('strftimemonthyear', 'langconfig')),
|
||||
'strftimerecent' => userdate($date, get_string('strftimerecent', 'langconfig')),
|
||||
'strftimerecentfull' => userdate($date, get_string('strftimerecentfull', 'langconfig')),
|
||||
'strftimetime' => userdate($date, get_string('strftimetime', 'langconfig'))
|
||||
);
|
||||
|
||||
return $dateformats;
|
||||
}
|
||||
|
@ -246,6 +257,8 @@ class element extends \mod_customcert\element {
|
|||
* @return string
|
||||
*/
|
||||
protected function get_date_format_string($date, $dateformat) {
|
||||
// Keeping for backwards compatibility.
|
||||
if (is_number($dateformat)) {
|
||||
switch ($dateformat) {
|
||||
case 1:
|
||||
$certificatedate = userdate($date, '%B %d, %Y');
|
||||
|
@ -263,6 +276,12 @@ class element extends \mod_customcert\element {
|
|||
default:
|
||||
$certificatedate = userdate($date, get_string('strftimedate', 'langconfig'));
|
||||
}
|
||||
}
|
||||
|
||||
// Ok, so we must have been passed the actual format in the lang file.
|
||||
if (!isset($certificatedate)) {
|
||||
$certificatedate = userdate($date, get_string($dateformat, 'langconfig'));
|
||||
}
|
||||
|
||||
return $certificatedate;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue