Date Format

bugs:341
bugs:56 - implemented with R5.0

The problem

The default formatting for dates and times in WackoWiki is pretty much hard coded thru out the PHP code. The day.month.year and year-month-day formats aren't natural for us westerners to read.

The solution

Adding some config options which allow the user to set the string passed into the date() function.

A patch

I've done an implementation from R4.2. You can download the patch here. The patch doesn't add defaults to 'wakka.config.php' file, so unless you're gonna re-run wacko setup you will need to add these manually. See the code block below.

Details

What i've done is add a few new items into the config. You'll have to add these yourself if your applying the patch or all hell will break loose.



"date_format" => "m/d/Y",
"time_format" => "h:i a",
"time_format_seconds" => "h:i:s a",
"name_date_macro" => "%s (%s)",
"date_macro_format" => "m/d/Y h:i a",

The format strings are passed into the PHP date() function. Use the the date() reference to understand what each character means.


The 'name_date_macro' isn't directly related to date formats, but it was a simple change. The first %s is the user name and the second %s is where the date goes. This little change allows you to change the formatting of this macro.

Future Implementation

My implementation works well, but could probably use some improvements. It's arguable if these things really belong in $wackoLanguage and not $config as it's sort of a localization issue. You could also argue that it's a matter of personal preference and belongs as part of the user settings.


Also the change i made for 'name_date_macro' should be expanded into a more powerful configuration language for wacko macros. Possibly in a way similar to how {{actions}} work.

Discussion


WackoWiki 6.1 implemented the IntlDateFormatter.

Comments

  1. Comment 130

    "date_format" => "d/m/Y",
    "time_format" => "H:i",
    "time_format_seconds" => "H:i",
    "name_date_macro" => "%s (%s)",
    "date_macro_format" => "d/m/Y H:i",
    "date_precise_format" => "d/m/Y H:i:s",	
  2. Comment 131

    "date_format" => "d.m.Y",
    "time_format" => "H:i:s",
    "time_format_seconds" => "H:i",
    "name_date_macro" => "%s (%s)",
    "date_macro_format" => "d.m.Y H:i",
    "date_precise_format" => "d.m.Y H:i:s",