San Sebastián - Tabla de mareas
'; foreach ($next_tides as $k => $v) { if ($k >= 0) { $mins_to_next_tide = $k; $tide_type = $v; break; } } $next_tide_time = date('h:i A T', strtotime("+$mins_to_next_tide minutes")); echo "
".time_till_tide($mins_to_next_tide * 60)." to $tide_type tide at $next_tide_time
"; $mins_to_next_tide_rounded = round_tide_time($mins_to_next_tide); $tide_image = select_tide_image($mins_to_next_tide_rounded,$tide_type); echo "
"; //echo $nexttidequarter; function next_tide_info ($tideinfo,$day) { global $time_offset_next_tide; //$tideinfo = ' High Tide: 2049 6.0'; //make an array out of the string, split on the space char after removing multiple spaces $t_arr = explode(" ", preg_replace('/\s\s+/', ' ',trim($tideinfo))); //print_r ($t_arr); //Array ( [0] => High [1] => Tide: [2] => 2049 [3] => 6.0 ) // now time in seconds $time_now = (time() - ($time_offset_next_tide * (60*60))); // get tide time in seconds. $t_hr = substr($t_arr[2], 0, 2); $t_min = substr($t_arr[2], -2); $t_time = strtotime(date("Y-m-d", $time_now + (86400 * $day))." $t_hr:$t_min:".date('s')); // next tide in minutes $t_diff = round(($t_time - $time_now) / 60); $next_t1 = array( "$t_diff" => strtolower($t_arr[0]), ); return $next_t1; } // end function mins_to_next_tide function round_tide_time ($mins_to_next_tide) { if($mins_to_next_tide <= 0) return 0; if($mins_to_next_tide >= 360) return 360; //echo "mins_to_next_tide: $mins_to_next_tide
"; $mins_to_next_tide = (round($mins_to_next_tide / 15) * 15); return $mins_to_next_tide; } // end function round_tide_time global $nexttidequarter; function select_tide_image ($mins_to_next_tide, $high_or_low) { global $nexttidequarter; if ($high_or_low == 'high') $nexttidequarter = "High$mins_to_next_tide"; if ($high_or_low == 'low') $nexttidequarter = "Low$mins_to_next_tide"; if($mins_to_next_tide <= 0) return $high_or_low . '_0.jpg'; if($mins_to_next_tide >= 360) return $high_or_low . '_360.jpg'; return $high_or_low . '_' . $mins_to_next_tide . '.jpg'; } // end function select_tide_image function time_till_tide ($time) { // takes a time diff like 6740 secs and formats to '1 hour, 52 minutes' $hrs = (int) intval($time / 3600); $time = (int) intval($time - (3600 * $hrs)); $mns = (int) intval($time / 60); $time = (int) intval($time - (60 * $mns)); $secs = (int) intval($time / 1); $hrs == 1 and $string .= "$hrs hour, "; $hrs > 1 and $string .= "$hrs hours, "; $string .= sprintf("%01d minutes", $mns); return $string; } function tide_data($numb) { global $tidefile,$yearDate, $convertRF; $tideD = implode('', file($tidefile)); $time = time(); // Get tide records by date, cut to length and split // If year is included in date if ($yearDate == "yes") { $tidedate = strstr($tideD, date("l Y-m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l Y-m-d", $time + (86400 * ($numb + 1)))); } else { $tidedate = strstr($tideD, date("l m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l m-d", $time + (86400 * ($numb + 1)))); //$tidedate = strstr($tideD, date("D m-d", $time + (86400 * $numb))); //$tideEnd = strpos($tideD, date("D m-d", $time + (86400 * ($numb + 1)))); } // The last tide will not show because it is not followed by a date. So we will // set the end possition to a fixed leangth if (!$tideEnd == false) { $tide = substr($tidedate, 0, $tideEnd); } else { $tide = substr($tidedate, 0, 280); } // Check if tides are in rising/falling format if (strstr($tide, "Rising")) { $risingFormat = "yes"; //$tide = substr($tidedate, 0, $tideEnd); } $tide = explode("\n", $tide); // Check if sunrise info is included if (strstr($tide[1], "Sunrise")) { $tide = $tide[0] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8] . "|" . $tide[9] . "|" . $tide[10]; $tide = explode("|", $tide); } else { $tide = $tide[0] . "|" . $tide[1] . "|" . $tide[2] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8]; $tide = explode("|", $tide); } return $tide; } // eof minutes to next tide>
'; foreach ($next_tides as $k => $v) { if ($k >= 0) { $mins_to_next_tide = $k; $tide_type = $v; break; } } $next_tide_time = date('h:i A T', strtotime("+$mins_to_next_tide minutes")); echo "
".time_till_tide($mins_to_next_tide * 60)." to $tide_type tide at $next_tide_time
"; $mins_to_next_tide_rounded = round_tide_time($mins_to_next_tide); $tide_image = select_tide_image($mins_to_next_tide_rounded,$tide_type); echo "
"; //echo $nexttidequarter; function next_tide_info ($tideinfo,$day) { global $time_offset_next_tide; //$tideinfo = ' High Tide: 2049 6.0'; //make an array out of the string, split on the space char after removing multiple spaces $t_arr = explode(" ", preg_replace('/\s\s+/', ' ',trim($tideinfo))); //print_r ($t_arr); //Array ( [0] => High [1] => Tide: [2] => 2049 [3] => 6.0 ) // now time in seconds $time_now = (time() - ($time_offset_next_tide * (60*60))); // get tide time in seconds. $t_hr = substr($t_arr[2], 0, 2); $t_min = substr($t_arr[2], -2); $t_time = strtotime(date("Y-m-d", $time_now + (86400 * $day))." $t_hr:$t_min:".date('s')); // next tide in minutes $t_diff = round(($t_time - $time_now) / 60); $next_t1 = array( "$t_diff" => strtolower($t_arr[0]), ); return $next_t1; } // end function mins_to_next_tide function round_tide_time ($mins_to_next_tide) { if($mins_to_next_tide <= 0) return 0; if($mins_to_next_tide >= 360) return 360; //echo "mins_to_next_tide: $mins_to_next_tide
"; $mins_to_next_tide = (round($mins_to_next_tide / 15) * 15); return $mins_to_next_tide; } // end function round_tide_time global $nexttidequarter; function select_tide_image ($mins_to_next_tide, $high_or_low) { global $nexttidequarter; if ($high_or_low == 'high') $nexttidequarter = "High$mins_to_next_tide"; if ($high_or_low == 'low') $nexttidequarter = "Low$mins_to_next_tide"; if($mins_to_next_tide <= 0) return $high_or_low . '_0.jpg'; if($mins_to_next_tide >= 360) return $high_or_low . '_360.jpg'; return $high_or_low . '_' . $mins_to_next_tide . '.jpg'; } // end function select_tide_image function time_till_tide ($time) { // takes a time diff like 6740 secs and formats to '1 hour, 52 minutes' $hrs = (int) intval($time / 3600); $time = (int) intval($time - (3600 * $hrs)); $mns = (int) intval($time / 60); $time = (int) intval($time - (60 * $mns)); $secs = (int) intval($time / 1); $hrs == 1 and $string .= "$hrs hour, "; $hrs > 1 and $string .= "$hrs hours, "; $string .= sprintf("%01d minutes", $mns); return $string; } function tide_data($numb) { global $tidefile,$yearDate, $convertRF; $tideD = implode('', file($tidefile)); $time = time(); // Get tide records by date, cut to length and split // If year is included in date if ($yearDate == "yes") { $tidedate = strstr($tideD, date("l Y-m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l Y-m-d", $time + (86400 * ($numb + 1)))); } else { $tidedate = strstr($tideD, date("l m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l m-d", $time + (86400 * ($numb + 1)))); //$tidedate = strstr($tideD, date("D m-d", $time + (86400 * $numb))); //$tideEnd = strpos($tideD, date("D m-d", $time + (86400 * ($numb + 1)))); } // The last tide will not show because it is not followed by a date. So we will // set the end possition to a fixed leangth if (!$tideEnd == false) { $tide = substr($tidedate, 0, $tideEnd); } else { $tide = substr($tidedate, 0, 280); } // Check if tides are in rising/falling format if (strstr($tide, "Rising")) { $risingFormat = "yes"; //$tide = substr($tidedate, 0, $tideEnd); } $tide = explode("\n", $tide); // Check if sunrise info is included if (strstr($tide[1], "Sunrise")) { $tide = $tide[0] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8] . "|" . $tide[9] . "|" . $tide[10]; $tide = explode("|", $tide); } else { $tide = $tide[0] . "|" . $tide[1] . "|" . $tide[2] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8]; $tide = explode("|", $tide); } return $tide; } // eof minutes to next tide>