<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     modifier
 * Name:     date_format
 * Purpose:  format datestamps via strftime
 * Input:    string: input date string
 *           format: strftime format for output
 *           default_date: default date if $string is empty
 * -------------------------------------------------------------
 */

function smarty_modifier_timestamp_format($string, $format = '%b %e, %Y', $default_date = null)
{
    if ($string != '') {
        return strftime($format, $string);
    } elseif (isset($default_date) && $default_date != '') {
        return strftime($format, $default_date);
    } else {
        return;
    }
}

/* vim: set expandtab: */
