#210 Allow short dates with leading zeros
This commit is contained in:
parent
ef285e6075
commit
9440dea72c
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,8 +286,14 @@ class element extends \mod_customcert\element {
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($strdateformats as $strdateformat) {
|
foreach ($strdateformats as $strdateformat) {
|
||||||
|
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'));
|
$dateformats[$strdateformat] = userdate($date, get_string($strdateformat, 'langconfig'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $dateformats;
|
return $dateformats;
|
||||||
}
|
}
|
||||||
|
@ -319,8 +329,14 @@ 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)) {
|
||||||
|
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'));
|
$certificatedate = userdate($date, get_string($dateformat, 'langconfig'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $certificatedate;
|
return $certificatedate;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue