Welcome Guest, Not a member yet? Register   Sign In
homemade helper isn't working
#5

[eluser]hht1230[/eluser]
Thanks for the welcome and the reply, anyway. I'm so far really loving CI, and glad to see this forum is so active. I don't think my helper functions are anything valuable for anyone else -- they are simple things like

function formatTime($s) {
if ($s == "0001") return ("");
else {
$h = intval(substr($s, 0, 2));
$m = intval(substr($s, 2, 2));
$ms = $m < 10 ? "0" . strval($m) : strval($m);
if ($h == 0) return ( "12:" . $ms . " am");
elseif ($h == 12) return ("12:" . $ms . " pm");
else return ( ($h > 12 ? $h-12 : strval($h)) . ":" . $ms . ($h > 12 ? " pm" : " am") );
}
}

which just format strings that I use in the way that I need them displayed, and I thought I'd try out the helper idea. Not sure if that's the best way, but I like the idea of saving reused functions away in logical groups.


Messages In This Thread
homemade helper isn't working - by El Forum - 07-16-2008, 07:11 PM
homemade helper isn't working - by El Forum - 07-16-2008, 07:51 PM
homemade helper isn't working - by El Forum - 07-16-2008, 07:51 PM
homemade helper isn't working - by El Forum - 07-16-2008, 07:52 PM
homemade helper isn't working - by El Forum - 07-16-2008, 08:09 PM
homemade helper isn't working - by El Forum - 07-16-2008, 08:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB