WackoWiki: Date Format

https://wackowiki.org/doc     Version: 27.03.2011 13:48
Dev[link6]/PatchesHacks[link7]/DateFormat
bugs:341[link1]
bugs:56[link2] – implemented with R5.0

The problem

The default formatting for dates and times in WackoWiki[link3] 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[link4]. 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[link5]. Use the the date() reference[link5] 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