<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (Canada/World-ML template set)
############################################################################
#
#   Project:    Sample Included Website Design
#   Module:     sample.php
#   Purpose:    Sample Page
#   Authors:    Kevin W. Reed <kreed@tnet.com>
#               TNET Services, Inc.
#
# 	Copyright:	(c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
#	This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE = langtransstr($SITE['organ']) . " - " .langtransstr('Records');
$showGizmo = true;  // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
/*
Note: add the translations for the following items to our language-LL.txt file to complete the translation

langlookup|Records began on|Records began on|
langlookup|Here are the extremes recorded since then|Here are the extremes recorded since then|
langlookup|Records Since|Records Since|
langlookup|Highest|Highest|
langlookup|Lowest|Lowest|
langlookup|Wind Chill|Wind Chill|
langlookup|Minimum|Minimum|
langlookup|Maximum|Maximum|
langlookup|Rainfall|Rainfall|
langlookup|Hourly Rainfall|Hourly Rainfall|
langlookup|Daily Rainfall|Daily Rainfall|
langlookup|Monthly Rainfall|Monthly Rainfall|
langlookup|Wind Gust|Wind Gust|
langlookup|Wind Speed Average|Wind Speed Average|

*/
?>

<div id="main-copy">
  
	<h1><?php langtrans('Records'); ?></h1>
    
<p><?php langtrans('Records began on'); ?> <?php print $WX['recordsbegandate']; ?>. <?php langtrans('Here are the extremes recorded since then'); ?>.</p>

<table width="100%" cellpadding="0" cellspacing="0" id="Current_Weather_Records">
   <caption><?php langtrans('Records Since'); ?> <?php print $WX['recordsbegandate']; ?></caption>
  <tr>
    <td colspan="3" class="table-top"><?php langtrans('Temperature'); ?> / <?php langtrans('Humidity'); ?> </td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Temperature'); ?></td>
    <td><?php print $WX['tempH']; ?> <?php print $SITE['uomTemp'];?></td>
    <td><?php print fix_CU_record_date($WX['TtempH']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Lowest'); ?> <?php langtrans('Temperature'); ?> </td>
    <td><?php print $WX['tempL']; ?> <?php print $SITE['uomTemp']; ?></td>
    <td><?php print fix_CU_record_date($WX['TtempL']); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Lowest'); ?> <?php langtrans('Wind Chill'); ?></td>
    <td><?php print $WX['wchillH']; ?> <?php print $SITE['uomTemp']; ?></td>
    <td><?php print fix_CU_record_date($WX['TwchillH']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Minimum'); ?> </td>
    <td><?php print $WX['mintempH']; ?> <?php print $SITE['uomTemp']; ?></td>
    <td><?php print fix_CU_record_date($WX['TmintempH']); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Lowest'); ?> <?php langtrans('Maximum'); ?> </td>
    <td><?php print $WX['maxtempL']; ?> <?php print $SITE['uomTemp']; ?></td>
    <td><?php print fix_CU_record_date($WX['TmaxtempL']); ?></td>
  </tr>
  <tr>
    <td colspan="3" class="table-top"><?php langtrans('Rainfall'); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Rain Rate'); ?></td>
    <td><?php print $WX['rrateM']; ?> <?php print $SITE['uomRain']; ?>/hr</td>
    <td><?php print fix_CU_record_date($WX['TrrateM']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Hourly Rainfall'); ?></td>
    <td><?php print $WX['rfallhH']; ?> <?php print $SITE['uomRain']; ?></td>
    <td><?php print fix_CU_record_date($WX['TrfallhH']); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Daily Rainfall'); ?></td>
    <td><?php print $WX['rfallH']; ?> <?php print $SITE['uomRain']; ?></td>
    <td><?php print fix_CU_record_date($WX['TrfallH']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Monthly Rainfall'); ?></td>
    <td><?php print $WX['rfallmH']; ?> <?php print $SITE['uomRain']; ?></td>
    <td><?php print fix_CU_record_date($WX['TrfallmH']); ?></td>
  </tr>
  <tr>
    <td colspan="3" class="table-top"><?php langtrans('Wind'); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Wind Gust'); ?></td>
    <td><?php print $WX['gustM']; ?> <?php print $SITE['uomWind']; ?></td>
    <td><?php print fix_CU_record_date($WX['TgustM']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Wind Speed Average'); ?></td>
    <td><?php print $WX['wspeedH']; ?> <?php print $SITE['uomWind']; ?></td>
    <td><?php print fix_CU_record_date($WX['TwspeedH']); ?></td>
  </tr>
  <tr>
    <td colspan="3" class="table-top"><?php langtrans('Barometer'); ?></td>
  </tr>
  <tr class="column-light">
    <td><?php langtrans('Lowest'); ?> <?php langtrans('Barometer'); ?></td>
    <td><?php print $WX['pressL']; ?> <?php print $SITE['uomBaro']; ?></td>
    <td><?php print fix_CU_record_date($WX['TpressL']); ?></td>
  </tr>
  <tr class="column-dark">
    <td><?php langtrans('Highest'); ?>  <?php langtrans('Barometer'); ?></td>
    <td><?php print $WX['pressH']; ?> <?php print $SITE['uomBaro']; ?></td>
    <td><?php print fix_CU_record_date($WX['TpressH']); ?></td>
  </tr>
</table>
    
</div><!-- end main-copy -->

<?php
function fix_CU_record_date( $inDate) {
global $SITE;
  $EnglishMonths = array(
   'January','February','March','April','May','June',
   'July','August','September','October','November','December');

// 'at 2:45 PM on 16 October 2009'	
	if(preg_match('|at (.*) on (.*)$|',$inDate,$matches)) {
	  echo "<!-- inDate='$inDate' date='".$matches[2]."' time='".$matches[1]."' -->\n";
	  $rdate = $matches[2];
	  if (isset($SITE['monthNames'])) {
		// convert TO English for strtotime()
		foreach ($EnglishMonths as $i => $monthEN) {
		   $rdate = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$rdate);
		}
	  }  
	  $t = strtotime($rdate . ' ' .$matches[1]);
	  $outTime = date($SITE['dateOnlyFormat'] . ' ' .$SITE['timeOnlyFormat'],$t);
	  if (isset($SITE['langMonths'])) {
        // convert From English for return (will only work if long-format month names in $timeFormat)  
    	foreach ($EnglishMonths as $i => $monthEN) {
	       $outTime = preg_replace('|'.$monthEN.'|i',$SITE['langMonths'][$i],$outTime);
    	}  
	  }
	  echo "<!-- outTime='$outTime' -->\n";
	  return($outTime);
	}
	if(preg_match('|on (.*)$|',$inDate,$matches)) {
		echo "<!-- inDate='$inDate' date='".$matches[1]."' -->\n";
		$rdate = $matches[1];
		if (isset($SITE['monthNames'])) {
		  // convert TO English for strtotime()
		  foreach ($EnglishMonths as $i => $monthEN) {
			 $rdate = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$rdate);
		  }
		}  
		$t = strtotime($rdate);
		$outTime = date($SITE['dateOnlyFormat'],$t);
		if (isset($SITE['langMonths'])) {
		  // convert From English for return (will only work if long-format month names in $timeFormat)  
		  foreach ($EnglishMonths as $i => $monthEN) {
			 $outTime = preg_replace('|'.$monthEN.'|i',$SITE['langMonths'][$i],$outTime);
		  }  
		}
		echo "<!-- outTime='$outTime' -->\n";
		return($outTime);
	}
	if(preg_match('|(\S+) (\d+)$|',$inDate,$matches)) {
		echo "<!-- inDate='$inDate' month='".$matches[1]."' year='".$matches[2]."' -->\n";
		$rdate = $matches[1];
		if (isset($SITE['monthNames'])) {
		  // convert TO English for strtotime()
		  foreach ($EnglishMonths as $i => $monthEN) {
			 $rdate = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$rdate);
		  }
		}  
		
		$t = strtotime($rdate . ' ' . $matches[2]);
		$idx = date('n',$t); // month number 1=january etc...
		
		$outTime = $SITE['langMonths'][$idx-1] . ' ' . $matches[2];
		echo "<!-- outTime='$outTime' -->\n";
		return($outTime);
	}
	
	
	return(trim($inDate));

}
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>