<?php
/************************************************************************
* *
* Copyright (C) 2001 Stuart Reeves *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* The GNU General Public License is available from: *
* http://www.gnu.org/copyleft/gpl.html *
* *
************************************************************************/
/* Stuart's lns (lame node system) */
/* Util provides useful library-style functions for STATIC method calls */
class Util
{
/* Formats the standard timestamp (YYYYMMDDHHMMSS)
*
* Args: $ts (string) - the timestamp to be formatted
*
* Returns: (string) - the formatted timestamp */
function fmtTimestamp($ts) {
if ($ts != "" || strlen($ts) != 10) {
// Parse the format into substrings
$year = substr($ts, 2, 2);
$month = substr($ts, 4, 2);
$day = substr($ts, 6, 2);
$hours = substr($ts, 8, 2);
$mins = substr($ts, 10, 2);
// Convert 24 hour to 12 hour
if (substr($hours, 0, 1) == "0")
$hours = substr($hours, 1, 1);
// return the string with am or pm
if ($hours < 12)
return "$hours:$mins" . "am - $day/$month/$year";
else {
$hours = $hours - 12;
if ($hours == 0)
$hours = 12;
return "$hours:$mins" . "pm - $day/$month/$year";
}
} else
return "(no date)";
}
/* Reseeds the random number generator, based on the current microsecond time
*
* Returns: null */
function reseed() {
// Seed with microseconds
list($usec, $sec) = explode(" ", microtime());
$seed = (float)$sec + ((float)$usec * 100000);
srand($seed);
}
/* Gets the current time in seconds and microseconds
*
* Returns: $sec - the time in seconds */
function getMicroSeconds() {
list($usec, $sec) = explode(" ", microtime());
$sec = (float)$usec + (float)$sec;
return $sec;
}
} // End class Util
?>