Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.9.9
-
None
-
MOODLE_19_STABLE
-
MOODLE_19_STABLE
Description
I added some lines to the code of block_birthday.php to deal with the most used date format in Spanish: DD/MM/YYY. The current version allow to choose from ISO (YYYY.MM.DD), USA (MM.DD.YYYY), and EUR (DD.MM.YYYY).
I added a new date format wich I called es_EUR (DD/MM/YYYY).
Modifications are very simple and basically consist on copy an existing 'switch - case' valid for a preexisting date format (for example EUR) and pasted again as es_EUR to work with a different format:
Additions in block_birthday.php are:
a.- In original file, line 7:
--------------------- Original ----------------------------
switch ($format)
-------------------End Original --------------------------
--------------------- Changes ----------------------------
switch ($format)
-------------------End Changes ----------------------------
b.- In original file, line 90:
--------------------- Original ----------------------------
switch ($dateformat)
-------------------End Original --------------------------
--------------------- Changes ----------------------------
switch ($dateformat)
-------------------End Changes ----------------------------
I'm not an expert in PHP, but I think changes don't concern security issues.
I also added new lines in config_global.html template to allow users to choose the new date format.
--------------------- Original ----------------------------
<td>
<select name="block_birthday_dateformat">
<option value="ISO" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "ISO")
}else{ echo "selected=\"selected\""; }?>
><?php p(get_string('dateformatiso', 'block_birthday')) ?></option>
<option value="USA" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "USA"){ echo "selected=\"selected\""; }
}?>
><?php p(get_string('dateformatusa', 'block_birthday')) ?></option>
<option value="EUR" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "EUR"){ echo "selected="selected""; }
}?>
><?php p(get_string('dateformateur', 'block_birthday')) ?></option>
</select>
</td>
--------------------- End Original ----------------------------
--------------------- Changes ----------------------------
<td>
<select name="block_birthday_dateformat">
<option value="ISO" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "ISO"){ echo "selected="selected"";}
}else
{ echo "selected=\"selected\""; }?>
><?php p(get_string('dateformatiso', 'block_birthday')) ?></option>
<option value="USA" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "USA")
}?>
><?php p(get_string('dateformatusa', 'block_birthday')) ?></option>
<option value="EUR" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "EUR"){ echo "selected="selected""; }
}?>
><?php p(get_string('dateformateur', 'block_birthday')) ?></option>
<option value="es_EUR" <?php if(isset($config_birthday->block_birthday_dateformat)){
if($config_birthday->block_birthday_dateformat == "EUR")
}?>
><?php p(get_string('dateformates_eur', 'block_birthday')) ?></option>
</select>
</td>
--------------------- End Changes ----------------------------
I've also added a new string to EACH ONE of the current lang translations to support this feature. Basically it consisted in add the line:
$string['dateformates_eur'] = 'es_EUR Date format: \'%%d/%%m/%%Y\'';
... to the existing ones.
A simple copy & paste let me mdified ALL the translations because the only thing I had to replace was 'EUR' by 'es_EUR'.
I have also made a new lang translations for 'Galician Language' that didn't exist (gl_utf8).
Finally I added to the README.TXT a reference to the es_EUR date format added.
I send you all the modifications in a attached zip file named birthday_modifications._2010_07_22.zip
I read in the discussion forum of birthday block that a Brazilian users asked for a date format as the one I tried to implement.
If you think that this customization is worth, let me know and I'll use it for my School. If not, I'll forget it.
Best regards form Vigo (Spain)
Toni Soto
Attachments
Issue Links
- has a non-specific relationship to
-
CONTRIB-2212 Birthday block doesn't works as expected for EUR dateformat
-
- Closed
-