<?php

/**

* Copyright 2007 Ryan Rhode, TY2U.com

* Date and Time Module for Joomla

* Displays the current time and date any way you want it.

* http://www.ty2u.com/date-and-time

*

*/

// no direct access

defined('_JEXEC') or defined( '_VALID_MOS' ) or die('Restricted access');



$showtime 				= $params->get( 'showtime' );

$showdate 				= $params->get( 'showdate' );



/* test to determine whether to proceed */

if ($showtime == 0 || $showdate == 0) {



	// include javascript in head tag

	$document = &JFactory::getDocument();

	$scriptpath = JURI::base() . '/modules/mod_date2/ty2udate.js';

	$document->addScript( $scriptpath );



	// store module parameters

	$moduleclass_sfx		= $params->get( 'moduleclass_sfx' );

	$pretext 				= $params->get( 'pretext' );

	$pretext 				= $params->get( 'pretext' );

	$posttext 				= $params->get( 'posttext' );

	$method			 		= $params->get( 'method' );

	$predate 				= $params->get( 'predate' );

	$postdate 				= $params->get( 'postdate' );

	$pretime 				= $params->get( 'pretime' );

	$posttime 				= $params->get( 'posttime' );

	$order 					= $params->get( 'order' );

	$seplines				= $params->get( 'seplines' );

	$align					= $params->get( 'align' );

	$dateorder				= $params->get( 'dateorder' );

	$suffixes 				= $params->get( 'suffixes' );

	$suntext 				= $params->get( 'suntext' );

	$montext 				= $params->get( 'montext' );

	$tuetext 				= $params->get( 'tuetext' );

	$wedtext 				= $params->get( 'wedtext' );

	$thutext 				= $params->get( 'thutext' );

	$fritext 				= $params->get( 'fritext' );

	$sattext 				= $params->get( 'sattext' );

	$monthformat 			= $params->get( 'monthformat' );

	$jantext 				= $params->get( 'jantext' );

	$febtext 				= $params->get( 'febtext' );

	$martext 				= $params->get( 'martext' );

	$aprtext 				= $params->get( 'aprtext' );

	$maytext 				= $params->get( 'maytext' );

	$juntext 				= $params->get( 'juntext' );

	$jultext 				= $params->get( 'jultext' );

	$augtext 				= $params->get( 'augtext' );

	$septext 				= $params->get( 'septext' );

	$octtext 				= $params->get( 'octtext' );

	$novtext 				= $params->get( 'novtext' );

	$dectext 				= $params->get( 'dectext' );

	$dst 					= $params->get( 'dst', 1 );

	$ISO8601		 		= $params->get( 'ISO8601' );

	$zone 					= $params->get( 'zone' );

	$dston 					= $params->get( 'dston' );

	$dstoff 				= $params->get( 'dstoff' );

	$military 				= $params->get( 'military' );

	$hours 					= $params->get( 'hours' );

	$minutes 				= $params->get( 'minutes' );

	$seconds 				= $params->get( 'seconds' );

	$ampm 					= $params->get( 'ampm' );

	$amtext 				= $params->get( 'amtext' );

	$pmtext 				= $params->get( 'pmtext' );

	$sepweek1 				= $params->get( 'sepweek1' );

	$sepweek2 				= $params->get( 'sepweek2' );

	$sepmonth1 				= $params->get( 'sepmonth1' );

	$sepmonth2 				= $params->get( 'sepmonth2' );

	$sepday1 				= $params->get( 'sepday1' );

	$sepday2 				= $params->get( 'sepday2' );

	$sepyear1 				= $params->get( 'sepyear1' );

	$sepyear2 				= $params->get( 'sepyear2' );

	$sephour1 				= $params->get( 'sephour1' );

	$sephour2 				= $params->get( 'sephour2' );

	$sepminute1 			= $params->get( 'sepminute1' );

	$sepminute2 			= $params->get( 'sepminute2' );

	$sepsecond1 			= $params->get( 'sepsecond1' );

	$sepsecond2 			= $params->get( 'sepsecond2' );

	$sepampm1 				= $params->get( 'sepampm1' );

	$sepampm2 				= $params->get( 'sepampm2' );

	$d1 					= $params->get( 'd1' );

	$d2 					= $params->get( 'd2' );

	$d3 					= $params->get( 'd3' );

	$d4 					= $params->get( 'd4' );

	$d5 					= $params->get( 'd5' );

	$d6 					= $params->get( 'd6' );

	$d7 					= $params->get( 'd7' );

	$d8 					= $params->get( 'd8' );

	$d9 					= $params->get( 'd9' );

	$d10 					= $params->get( 'd10' );

	$d11 					= $params->get( 'd11' );

	$d12 					= $params->get( 'd12' );

	$d13 					= $params->get( 'd13' );

	$d14 					= $params->get( 'd14' );

	$d15 					= $params->get( 'd15' );

	$d16 					= $params->get( 'd16' );

	$d17 					= $params->get( 'd17' );

	$d18 					= $params->get( 'd18' );

	$d19 					= $params->get( 'd19' );

	$d20 					= $params->get( 'd20' );

	$d21 					= $params->get( 'd21' );

	$d22 					= $params->get( 'd22' );

	$d23 					= $params->get( 'd23' );

	$d24 					= $params->get( 'd24' );

	$d25 					= $params->get( 'd25' );

	$d26 					= $params->get( 'd26' );

	$d27 					= $params->get( 'd27' );

	$d28 					= $params->get( 'd28' );

	$d29 					= $params->get( 'd29' );

	$d30 					= $params->get( 'd30' );

	$d31 					= $params->get( 'd31' );



	//if the dateorder box is empty then don't show the date

	if (empty($dateorder)) {

		$showdate = 1;

	}



	//set alignment

	if($align=="1"){

		$alignment="left";

	}

	if($align=="2"){

		$alignment="center";

	}

	if($align=="3"){

		$alignment="right";

	}

	if($align != "0"){

		echo "<div style=\"margin:0px auto;width:auto;text-align:".$alignment.";\">";

	}



	#echo $pretext."<span id=\"ty2udate" . $module->id . "\"></span>".$posttext;	Thank you to moderntalking for this fix!

	echo $pretext."<span id=\"ty2udate" . $module->id . "\">";



	//variables to clean up the strings a bit

	$stripthis 	= array("\"\"","++++","+++","++","�");

	$addthis 	= array(""    ,"+"   ,"+"  ,"+" ," " );



	if ($method==0) {

	//javascript method



	$theDate = "";



	//compile javascript date based on desired date order

	if ($showdate==0 && !empty($dateorder)) {



		//explode date order

		$exorder = explode(",", $dateorder);



		for ($i = 0; $i <= 3; $i++) {

		

			// check variable to prevent php notice - thanks to jonusc

			if (!isset($exorder[$i])) break;



			switch ($exorder[$i]) {

			case 'w':

				//make weekday with prefix and suffix

				if($i > 0){

					if ($exorder[$i-1]!="") {

						$theDate .= "+";

					}

				}

				$theDate .= '';

				if(count($exorder) < $i+1){

					if ($exorder[$i+1]!="") {

						$theDate .= "+";

					}

				}

				break;

			case 'd':

				//make day with prefix and suffix

				if($i > 0){

					if ($exorder[$i-1]!="") {

						$theDate .= "+";

					}

				}

				if ($suffixes==0) {

					$theDate .= "\"".$sepday1."\"+ardate".$module->id."[myweekday".$module->id."]+\"".$sepday2."\"";

				}else {

					$theDate .= "\"".$sepday1."\"+myweekday".$module->id."+\"".$sepday2."\"";

				}

				if(count($exorder) < $i+1){

					if ($exorder[$i+1]!="") {

						$theDate .= "+";

					}

				}

				break;

			case 'm':

				//make month with prefix and suffix

				if($i > 0){

					if ($exorder[$i-1]!="") {

						$theDate .= "+";

					}

				}

				if ($monthformat==0) {

					$theDate .= "\"".$sepmonth1."\"+armonth".$module->id."[mymonth".$module->id."]+\"".$sepmonth2."\"";

				}else {

					$theDate .= "\"".$sepmonth1."\"+mymonth".$module->id."+\"".$sepmonth2."\"";

				}

				if(count($exorder) < $i+1){

					if ($exorder[$i+1]!="") {

						$theDate .= "+";

					}

				}

				break;

			case 'y':

				//make year with prefix and suffix

				if($i > 0){

					if ($exorder[$i-1]!="") {

						$theDate .= "+";

					}

				}

				$theDate .= "\"".$sepyear1."\"+year".$module->id."+\"".$sepyear2."\"";

				if(count($exorder) < $i+1){

					if ($exorder[$i+1]!="") {

						$theDate .= "+";

					}

				}

				break;

			default:

				$theDate .= "\"\"";

			}

		}



		//clean up strings

		$theDate 	= str_replace($stripthis, $addthis, $theDate);

		$theDate 	= trim($theDate, "+");



		//add suffix

		$theDate	= $theDate."+\"".$postdate."\"";

	}



	$theTime = "\"".$sepweek1."\"+arday".$module->id."[myday".$module->id."]+\"".$sepweek2."\"";



	//compile javascript time based on paramaters

	if ($showtime==0) {

		if ($hours==0) {

			$theTime .= "\"".$sephour1."\"+myhours".$module->id."+\"".$sephour2."\"";

		}

		if ($minutes==0) {

			$theTime .= "\"".$sepminute1."\"+mytime".$module->id."+\"".$sepminute2."\"";

		}

		if ($seconds==0) {

			$theTime .= "\"".$sepsecond1."\"+myseconds".$module->id."+\"".$sepsecond2."\"";

		}

		if ($ampm==0 && $military==1) {

			$theTime .= "\"".$sepampm1."\"+mm".$module->id."+\"".$sepampm2."\"";

		}



		//clean up strings

		$theTime 	= str_replace($stripthis, $addthis, $theTime);

		$theTime 	= trim($theTime, "+");



		//add suffix

		$theTime	= $theTime."+\"".$posttime."\"";

	}



	?>

	<script language="javascript" type="text/javascript">

	<!--

	function ISO8601Local<?php echo $module->id; ?>(date) {

	// handles years from 0000 to 9999 only

		var offset<?php echo $module->id; ?> = date.getTimezoneOffset();

		var offsetSign<?php echo $module->id; ?> = "-";

		if (offset<?php echo $module->id; ?> <= 0) {

			offsetSign<?php echo $module->id; ?> = "+";

			offset<?php echo $module->id; ?> = -offset<?php echo $module->id; ?>;

		}

		var offsetHours<?php echo $module->id; ?> = Math.floor(offset<?php echo $module->id; ?> / 60);

		var offsetMinutes<?php echo $module->id; ?> = offset<?php echo $module->id; ?> - offsetHours<?php echo $module->id; ?> * 60;

		return ("000" + date.getFullYear()).slice(-4) +

		"-" + ("0" + (date.getMonth() + 1)).slice(-2) +

		"-" + ("0" + date.getDate()).slice(-2) +

		"T" + ("0" + date.getHours()).slice(-2) +

		":" + ("0" + date.getMinutes()).slice(-2) +

		":" + ("0" + date.getSeconds()).slice(-2) +

		"," + ("00" + date.getMilliseconds()).slice(-3) +

		offsetSign<?php echo $module->id; ?> + ("0" + offsetHours<?php echo $module->id; ?>).slice(-2) +

		":" + ("0" + offsetMinutes<?php echo $module->id; ?>).slice(-2);

	}



	var ISO8601<?php echo $module->id; ?> = "<?php echo $ISO8601; ?>";



	function clock<?php echo $module->id; ?>() {

		var newdate<?php echo $module->id; ?> = new Date();



		if(ISO8601<?php echo $module->id; ?> == "1") {



			var time<?php echo $module->id; ?> = ISO8601Local<?php echo $module->id; ?>(newdate<?php echo $module->id; ?>);



		} else {



			var day<?php echo $module->id; ?>="";

			var month<?php echo $module->id; ?>="";

			var myweekday<?php echo $module->id; ?>="";

			var year<?php echo $module->id; ?>="";

			var mydate<?php echo $module->id; ?> = new Date();

			var dston<?php echo $module->id; ?>  =  new  Date('<?php echo $dston; ?>');

			var dstoff<?php echo $module->id; ?> = new Date('<?php echo $dstoff; ?>');

			dston<?php echo $module->id; ?>.setFullYear(newdate<?php echo $module->id; ?>.getFullYear());

			dstoff<?php echo $module->id; ?>.setFullYear(newdate<?php echo $module->id; ?>.getFullYear());



			var dst<?php echo $module->id; ?> = "<?php echo $dst; ?>";

			var myzone<?php echo $module->id; ?> = newdate<?php echo $module->id; ?>.getTimezoneOffset();



			var zone<?php echo $module->id; ?> = <?php echo $zone; ?>;

			

			// zone is negative so convert to positive to do calculations

			if (zone<?php echo $module->id; ?> <= 0) {

				zoneb<?php echo $module->id; ?> = -zone<?php echo $module->id; ?>;

			} else {

				zoneb<?php echo $module->id; ?> = zone<?php echo $module->id; ?>;

			}

			

			if (mydate<?php echo $module->id; ?> > dston<?php echo $module->id; ?> && mydate<?php echo $module->id; ?> < dstoff<?php echo $module->id; ?> && dst<?php echo $module->id; ?> == "1") {

			//date is between dst dates and dst adjust is on.

				zonea<?php echo $module->id; ?> = zoneb<?php echo $module->id; ?> - 1;

				var houradjust<?php echo $module->id; ?> = 0;

			} else {

				zonea<?php echo $module->id; ?> = zoneb<?php echo $module->id; ?>;

				var houradjust<?php echo $module->id; ?> = -1;

			};



			newtime<?php echo $module->id; ?>=newdate<?php echo $module->id; ?>.getTime();



			var newzone<?php echo $module->id; ?> =  (zonea<?php echo $module->id; ?>*60*60*1000);



			// convert zone back to negative if it was negative originally

			if (zone<?php echo $module->id; ?> <= 0) {

				newzone<?php echo $module->id; ?> = -newzone<?php echo $module->id; ?>;

			}

			newtimea<?php echo $module->id; ?> = newtime<?php echo $module->id; ?>+(myzone<?php echo $module->id; ?>*60*1000)+newzone<?php echo $module->id; ?>;



			mydate<?php echo $module->id; ?>.setTime(newtimea<?php echo $module->id; ?>);

			myday<?php echo $module->id; ?> = mydate<?php echo $module->id; ?>.getDay();

			mymonth<?php echo $module->id; ?> = mydate<?php echo $module->id; ?>.getMonth();

			myweekday<?php echo $module->id; ?>= mydate<?php echo $module->id; ?>.getDate();

			myyear<?php echo $module->id; ?>= mydate<?php echo $module->id; ?>.getYear();

			year<?php echo $module->id; ?> = myyear<?php echo $module->id; ?>;



			if (year<?php echo $module->id; ?> < 2000) year<?php echo $module->id; ?> = year<?php echo $module->id; ?> + 1900;

			myhours<?php echo $module->id; ?> = mydate<?php echo $module->id; ?>.getHours();



			<?php

			if ($military=="1") {

			//not using military time

			?>



			var mm<?php echo $module->id; ?> = "<?php echo $amtext; ?>";

			if (myhours<?php echo $module->id; ?> > 11 + houradjust<?php echo $module->id; ?>)

				mm<?php echo $module->id; ?> = "<?php echo $pmtext; ?>";

			if (myhours<?php echo $module->id; ?> > 12 + houradjust<?php echo $module->id; ?>)

				myhours<?php echo $module->id; ?> -= 12;

			if (myhours<?php echo $module->id; ?> == 0) myhours<?php echo $module->id; ?> = 12;



			<?php

			}else{

			//using military time

			?>



				if (myhours<?php echo $module->id; ?> < 10){

					myhours<?php echo $module->id; ?> = "0" + myhours<?php echo $module->id; ?>;

				}

				else {

					myhours<?php echo $module->id; ?> = "" + myhours<?php echo $module->id; ?>;

				};



			<?php

			}

			?>



			myminutes<?php echo $module->id; ?> = mydate<?php echo $module->id; ?>.getMinutes();



			if (myminutes<?php echo $module->id; ?> < 10){

				mytime<?php echo $module->id; ?> = "0" + myminutes<?php echo $module->id; ?>;

			}

			else {

				mytime<?php echo $module->id; ?> = "" + myminutes<?php echo $module->id; ?>;

			};



			myseconds<?php echo $module->id; ?> = mydate<?php echo $module->id; ?>.getSeconds();



			if (myseconds<?php echo $module->id; ?> < 10) {

				myseconds<?php echo $module->id; ?> = "0" + myseconds<?php echo $module->id; ?>;

			} else {

				myseconds<?php echo $module->id; ?> = "" + myseconds<?php echo $module->id; ?>;

			};



			arday<?php echo $module->id; ?> = new Array("<?php echo $suntext; ?>","<?php echo $montext; ?>","<?php echo $tuetext; ?>","<?php echo $wedtext; ?>","<?php echo $thutext; ?>","<?php echo $fritext; ?>","<?php echo $sattext; ?>")

			armonth<?php echo $module->id; ?> = new Array("<?php echo $jantext; ?>","<?php echo $febtext; ?>","<?php echo $martext; ?>","<?php echo $aprtext; ?>","<?php echo $maytext; ?>","<?php echo $juntext; ?>","<?php echo $jultext; ?>","<?php echo $augtext; ?>","<?php echo $septext; ?>", "<?php echo $octtext; ?>","<?php echo $novtext; ?>","<?php echo $dectext; ?>")

			ardate<?php echo $module->id; ?> = new Array("0th","<?php echo $d1; ?>","<?php echo $d2; ?>","<?php echo $d3; ?>","<?php echo $d4; ?>","<?php echo $d5; ?>","<?php echo $d6; ?>","<?php echo $d7; ?>","<?php echo $d8; ?>","<?php echo $d9; ?>","<?php echo $d10; ?>","<?php echo $d11; ?>","<?php echo $d12; ?>","<?php echo $d13; ?>","<?php echo $d14; ?>","<?php echo $d15; ?>","<?php echo $d16; ?>","<?php echo $d17; ?>","<?php echo $d18; ?>","<?php echo $d19; ?>","<?php echo $d20; ?>","<?php echo $d21; ?>","<?php echo $d22; ?>","<?php echo $d23; ?>","<?php echo $d24; ?>","<?php echo $d25; ?>","<?php echo $d26; ?>","<?php echo $d27; ?>","<?php echo $d28; ?>","<?php echo $d29; ?>","<?php echo $d30; ?>","<?php echo $d31; ?>");



			<?php

			//add prefixes and a line break if they are wanted



			if ($showdate==0 && !empty($dateorder)) {

				$datebreak="";

				if ($seplines == 0 && $order == 1) $datebreak="<br />";

				$predate="\"".$datebreak.$predate."\"+";

			}else{

				$predate="";

			}



			if ($showtime==0) {

				$timebreak="";

				if ($seplines == 0 && $order == 0) $timebreak="<br />";

				$pretime="\"".$timebreak.$pretime."\"+";

			}else{

				$pretime="";

			}



			//adjust some date values if required

			if ($suffixes==1) {

			?>

				myweekday<?php echo $module->id; ?> = parseInt(myweekday<?php echo $module->id; ?>);

			<?php

			}

			if ($monthformat==1) {

			?>

				mymonth<?php echo $module->id; ?> = parseInt(mymonth<?php echo $module->id; ?>)+1;

			<?php

			}



			if ($order == 0 && ($showdate == 0 || $showtime == 0)) {

			//date should be shown first



				if(!empty($theTime) && $showdate == 0) {

					$theDate .= "+";

				}



				?>



				var time<?php echo $module->id; ?> = (<?php echo $predate; ?><?php echo $theDate; ?><?php echo $pretime; ?><?php echo $theTime; ?>);



				<?php



			} elseif ($order == 1 && ($showdate == 0 || $showtime == 0)) {

			//time should be shown first



				if(!empty($theDate) && $showtime == 0) {

					$theTime .= "+";

				}



				?>



				var time<?php echo $module->id; ?> = (<?php echo $pretime; ?><?php echo $theTime; ?><?php echo $predate; ?><?php echo $theDate; ?>);



			<?php

			}

			?>

	}



	document.getElementById('ty2udate<?php echo $module->id; ?>').innerHTML  = time<?php echo $module->id; ?>;



	setTimeout("clock<?php echo $module->id; ?>()", 1000)



	}

	listen("load", window, clock<?php echo $module->id; ?>);

	//-->

	</script>



	<?php

	} else {

	//php method



		if($ISO8601 == 1) {

		//ISO 8601 format



			if($zone < 0){

				$time = date("c", strtotime($zone." hours"));

			} else if ($zone > 0) {

				$time = date("c", strtotime("+".$zone." hours"));

			} else if ($zone == 0) {

				$time = date("c");

			}



		} else {

		//user defined format

		

			//adjust for DST

			if (date("I") && $dst == "1") {

					$zone++;

			}



			//time adjustment

			if($zone < 0){

				if ($military=="1") {

					$parts = date("w,j,m,Y,g,i,s", strtotime($zone." hours"));

				}else{

					$parts = date("w,j,m,Y,H,i,s", strtotime($zone." hours"));

				}

			} else if ($zone > 0) {

				if ($military=="1") {

					$parts = date("w,j,m,Y,g,i,s", strtotime("+".$zone." hours"));

				}else{

					$parts = date("w,j,m,Y,H,i,s", strtotime("+".$zone." hours"));

				}

			} else if ($zone == 0) {

				if ($military=="1") {

					$parts = date("w,j,m,Y,g,i,s");

				}else{

					$parts = date("w,j,m,Y,H,i,s");

				}

			}



			//explode parts after adjustments

			$parts = explode(",", $parts);



			$weekday 	= $parts[0];

			$day 		= $parts[1];

			$month 		= $parts[2];

			$year 		= $parts[3];

			$hour 		= $parts[4];

			$minute 	= $parts[5];

			$second 	= $parts[6];



			//text arrays

			$daytext = array($suntext,$montext,$tuetext,$wedtext,$thutext,$fritext,$sattext);

			$suffixtext = array("0th",$d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$d10,$d11,$d12,$d13,$d14,$d15,$d16,$d17,$d18,$d19,$d20,$d21,$d22,$d23,$d24,$d25,$d26,$d27,$d28,$d29,$d30,$d31);

			$monthtext = array($jantext,$febtext,$martext,$aprtext,$maytext,$juntext,$jultext,$augtext,$septext,$octtext,$novtext,$dectext);



			//add prefixes and a line break if they are wanted

			if ($showdate==0 && !empty($dateorder)) {

				$datebreak="";

				if ($seplines == 0 && $order == 1) {

						$datebreak="<br />";

					}

					$predate=$datebreak.$predate;

			}else{

				$predate="";

			}

			if ($showtime==0) {

					$timebreak="";

					if ($seplines == 0 && $order == 0) {

						$timebreak="<br />";

					}

					$pretime=$timebreak.$pretime;

			}else{

				$pretime="";

			}



			//adjust month if using text

			if ($monthformat==0) {

				$month = intval($month)-1;

			}



			//compile php date based on desired date order

			if ($showdate==0 && !empty($dateorder)) {



				//explode date order

				$exorder = explode(",", $dateorder);



				$theDate = "";

				for ($i = 0; $i <= 3; $i++) {

					switch ($exorder[$i]) {

					case 'w':

						//make weekday with prefix and suffix

						$theDate .= $sepweek1.$daytext[$weekday].$sepweek2;

						break;

					case 'd':

						//make day with prefix and suffix

						if ($suffixes==0) {

							$theDate .= $sepday1.$suffixtext[$day].$sepday2;

						}else {

							$theDate .= $sepday1.$day.$sepday2;

						}

						break;

					case 'm':

						//make month with prefix and suffix

						if ($monthformat==0) {

							$theDate .= $sepmonth1.$monthtext[$month].$sepmonth2;

						}else {

							$theDate .= $sepmonth1.$month.$sepmonth2;

						}

						break;

					case 'y':

						//make year with prefix and suffix

						$theDate .= $sepyear1.$year.$sepyear2;

						break;

					default:

						$theDate .= "";

					}

				}

			}



			$theTime = "";

			

			//compile php time based on paramaters

			if ($showtime==0) {

				if ($hours==0) {

					$theTime .= $sephour1.$hour.$sephour2;

				}

				if ($minutes==0) {

					$theTime .= $sepminute1.$minute.$sepminute2;

				}

				if ($seconds==0) {

					$theTime .= $sepsecond1.$second.$sepsecond2;

				}

				if ($ampm==0 && $military==1) {

					if (date("a")=="am") {

						$theTime .= $sepampm1.$amtext.$sepampm2;

					}else{

						$theTime .= $sepampm1.$pmtext.$sepampm2;

					}

				}

			}



			if ($order == 0) {

			//date should be shown first



				if(!empty($theDate)) {

					$theDate .= "";

				}



				$time = ($predate.$theDate.$postdate.$pretime.$theTime.$posttime);



			} else {

			//time should be shown first



				if(!empty($theTime)) {

					$theTime .= "";

				}



				$time = ($pretime.$theTime.$posttime.$predate.$theDate.$postdate);

			}

		}



		//clean up strings

		$time 	= str_replace($stripthis, $addthis, $time);

		$time 	= trim($time, "+");



		echo $time;



	}

/*	Thank you to moderntalking for this fix!  v2.1.8

	if($align != "0"){

		echo "</div>";

	}

*/

echo "</span>".$posttext;

if($align != "0"){

echo "</div>";

}



}

?>