Last active
August 29, 2015 13:56
-
-
Save mckelvey/9262446 to your computer and use it in GitHub Desktop.
This tiny LiveWhale application module alters the time and meridian formatting from the PHP-based LiveWhale defaults.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_LW->REGISTERED_APPS['time_formatter']=array( | |
'title'=>'Time Formatter', | |
'handlers'=>array('onWidgetFormat'), | |
); | |
class LiveWhaleApplicationTimeFormatter { | |
public function onWidgetFormat($type, $handler, $variables) { // alter widget variables | |
global $_LW; | |
if ($type === 'events' && $handler === 'onDisplay' && array_key_exists('time', $variables)) { // find events widgets with time output | |
$variables['time'] = preg_replace('~(\d+)(a|p)(m)~i', '$1 $2.$3.', $variables['time']); // reformat am, pm to have periods and always be lowercase | |
$variables['time'] = str_replace(':00', '', $variables['time']); // remove :00 from times | |
} | |
return $variables; // and return the variables | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment