#210 Allow short dates with leading zeros
This commit is contained in:
parent
c66fb9703d
commit
f76ec6e841
1 changed files with 19 additions and 3 deletions
|
@ -256,7 +256,9 @@ class element extends \mod_customcert\element {
|
||||||
* @return array the list of date formats
|
* @return array the list of date formats
|
||||||
*/
|
*/
|
||||||
public static function get_date_formats() {
|
public static function get_date_formats() {
|
||||||
$date = time();
|
// Hard-code date so users can see the difference between short dates with and without the leading zero.
|
||||||
|
// Eg. 06/07/18 vs 6/07/18.
|
||||||
|
$date = 1530849658;
|
||||||
|
|
||||||
$suffix = self::get_ordinal_number_suffix(userdate($date, '%d'));
|
$suffix = self::get_ordinal_number_suffix(userdate($date, '%d'));
|
||||||
|
|
||||||
|
@ -268,9 +270,11 @@ class element extends \mod_customcert\element {
|
||||||
$strdateformats = [
|
$strdateformats = [
|
||||||
'strftimedate',
|
'strftimedate',
|
||||||
'strftimedatefullshort',
|
'strftimedatefullshort',
|
||||||
|
'strftimedatefullshortwleadingzero',
|
||||||
'strftimedateshort',
|
'strftimedateshort',
|
||||||
'strftimedatetime',
|
'strftimedatetime',
|
||||||
'strftimedatetimeshort',
|
'strftimedatetimeshort',
|
||||||
|
'strftimedatetimeshortwleadingzero',
|
||||||
'strftimedaydate',
|
'strftimedaydate',
|
||||||
'strftimedaydatetime',
|
'strftimedaydatetime',
|
||||||
'strftimedayshort',
|
'strftimedayshort',
|
||||||
|
@ -282,7 +286,13 @@ class element extends \mod_customcert\element {
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($strdateformats as $strdateformat) {
|
foreach ($strdateformats as $strdateformat) {
|
||||||
$dateformats[$strdateformat] = userdate($date, get_string($strdateformat, 'langconfig'));
|
if ($strdateformat == 'strftimedatefullshortwleadingzero') {
|
||||||
|
$dateformats[$strdateformat] = userdate($date, get_string('strftimedatefullshort', 'langconfig'), 99, false);
|
||||||
|
} else if ($strdateformat == 'strftimedatetimeshortwleadingzero') {
|
||||||
|
$dateformats[$strdateformat] = userdate($date, get_string('strftimedatetimeshort', 'langconfig'), 99, false);
|
||||||
|
} else {
|
||||||
|
$dateformats[$strdateformat] = userdate($date, get_string($strdateformat, 'langconfig'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dateformats;
|
return $dateformats;
|
||||||
|
@ -319,7 +329,13 @@ class element extends \mod_customcert\element {
|
||||||
|
|
||||||
// Ok, so we must have been passed the actual format in the lang file.
|
// Ok, so we must have been passed the actual format in the lang file.
|
||||||
if (!isset($certificatedate)) {
|
if (!isset($certificatedate)) {
|
||||||
$certificatedate = userdate($date, get_string($dateformat, 'langconfig'));
|
if ($dateformat == 'strftimedatefullshortwleadingzero') {
|
||||||
|
$certificatedate = userdate($date, get_string('strftimedatefullshort', 'langconfig'), 99, false);
|
||||||
|
} else if ($dateformat == 'strftimedatetimeshortwleadingzero') {
|
||||||
|
$certificatedate = userdate($date, get_string('strftimedatetimeshort', 'langconfig'), 99, false);
|
||||||
|
} else {
|
||||||
|
$certificatedate = userdate($date, get_string($dateformat, 'langconfig'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $certificatedate;
|
return $certificatedate;
|
||||||
|
|
Loading…
Reference in a new issue