#210 Improve code for adding date strings to select

This commit is contained in:
Mark Nelson 2018-07-12 16:51:10 +08:00
parent 83f337f5c4
commit 3f082b7e56

View file

@ -260,23 +260,30 @@ class element extends \mod_customcert\element {
$suffix = self::get_ordinal_number_suffix(userdate($date, '%d')); $suffix = self::get_ordinal_number_suffix(userdate($date, '%d'));
$dateformats = array( $dateformats = [
1 => userdate($date, '%B %d, %Y'), 1 => userdate($date, '%B %d, %Y'),
2 => userdate($date, '%B %d' . $suffix . ', %Y'), 2 => userdate($date, '%B %d' . $suffix . ', %Y')
'strftimedate' => userdate($date, get_string('strftimedate', 'langconfig')), ];
'strftimedatefullshort' => userdate($date, get_string('strftimedatefullshort', 'langconfig')),
'strftimedateshort' => userdate($date, get_string('strftimedateshort', 'langconfig')), $strdateformats = [
'strftimedatetime' => userdate($date, get_string('strftimedatetime', 'langconfig')), 'strftimedate',
'strftimedatetimeshort' => userdate($date, get_string('strftimedatetimeshort', 'langconfig')), 'strftimedatefullshort',
'strftimedaydate' => userdate($date, get_string('strftimedaydate', 'langconfig')), 'strftimedateshort',
'strftimedaydatetime' => userdate($date, get_string('strftimedaydatetime', 'langconfig')), 'strftimedatetime',
'strftimedayshort' => userdate($date, get_string('strftimedayshort', 'langconfig')), 'strftimedatetimeshort',
'strftimedaytime' => userdate($date, get_string('strftimedaytime', 'langconfig')), 'strftimedaydate',
'strftimemonthyear' => userdate($date, get_string('strftimemonthyear', 'langconfig')), 'strftimedaydatetime',
'strftimerecent' => userdate($date, get_string('strftimerecent', 'langconfig')), 'strftimedayshort',
'strftimerecentfull' => userdate($date, get_string('strftimerecentfull', 'langconfig')), 'strftimedaytime',
'strftimetime' => userdate($date, get_string('strftimetime', 'langconfig')) 'strftimemonthyear',
); 'strftimerecent',
'strftimerecentfull',
'strftimetime'
];
foreach ($strdateformats as $strdateformat) {
$dateformats[$strdateformat] = userdate($date, get_string($strdateformat, 'langconfig'));
}
return $dateformats; return $dateformats;
} }