Exemplo n.º 1
0
 public function bite_calculator()
 {
     $this->load->helper('path');
     $this->load->helper('date');
     $this->load->view('resources/head_calc');
     /*********************************************************************/
     /* Here is an example of how to get the users inputs from a form
      * that is pre-loaded with todays date
      */
     $post = array('pyear' => $this->input->post('pyear'), 'pmonth' => $this->input->post('pmonth'), 'pday' => $this->input->post('pday'), 'tz' => $this->input->post('tz'), 'lat' => $this->input->post('lat'), 'long' => $this->input->post('long'));
     if ($post == FALSE) {
         //  no post yet so use default values
         $year = mdate("Year: %Y ");
         $month = mdate('Month: %m');
         $day = mdate('Day: %d ');
         $tz = -5;
         $lat = 40.5;
         $underlong = -80.5;
     } else {
         //  use post values
         $year = (int) $post['pyear'];
         $month = (int) $post['pmonth'];
         $day = (int) $post['pday'];
         $tz = (int) $post['tz'];
         $lat = (double) $post['lat'];
         $underlong = (double) $post['long'];
     }
     $UT = 0.0;
     $this->load->view('resources/bitetime-calculator');
     /*********************************************************************/
     /* HERE IS WHAT YOU WANT!!!!
      * 
      * The folowing function calls are all you need to get the RAW data
      * These function calls require the following variables to already be
      * set: $year, $month, $day, $tz, $lat, $underlong, $UT
      * 
      * $year -> year part of date we will calculate for in yyyy format. example 2008
      * &month -> month part of date we will calculate for in mm format. example 2 or 02
      * $day -> day part of date we will calculate for in dd format. example 2 or 02
      * $tz -> timezone offset to calculate results in. example -5 for EST
      * $lat -> latitude (NEGATIVE NUMBERS ARE WEST)
      * $underlong -> longitude  (NEGATIVE NUMBERS ARE SOUTH)
      * $UT = 0.0, Universal time, keep this set at zero, its for the julian
      * date calculations, for our purposes we only need the julian date at
      * the start of the day, however  I might change that in later versions.
      * 
     /*********************************************************************/
     //get dates
     $JD = $this->get_Julian_Date($year, $month, $day, $UT);
     $date = $JD - 2400000.5 - $tz / 24.0;
     /*********************************************************************/
     //get rise, set and transit times for moon and sun
     get_rst(1, $date, 0.0 - $underlong, $lat, $sunrise, $sunset, $suntransit);
     get_rst(0, $date, 0.0 - $underlong, $lat, $moonrise, $moonset, $moontransit);
     $moonunder = get_underfoot($date, $underlong);
     /*********************************************************************/
     //get solunar minor periods
     sol_get_minor1($minorstart1, $minorstop1, $moonrise);
     sol_get_minor2($minorstart2, $minorstop2, $moonset);
     /*********************************************************************/
     //get solunar major periods
     sol_get_major1($majorstart1, $majorstop1, $moontransit);
     sol_get_major2($majorstart2, $majorstop2, $moonunder);
     /*********************************************************************/
     //get moon phase
     $moonage = get_moon_phase($JD, $PhaseName, $illumin);
     /*********************************************************************/
     //get day scale
     $phasedayscale = phase_day_scale($moonage);
     $soldayscale = sol_get_dayscale($moonrise, $moonset, $moontransit, $sunrise, $sunset);
     /*********************************************************************/
     /* at this point we have raw data times in decimal
      * time format. 
     */
     /*********************************************************************/
     /*
      * Here is an example on how to convert the results to 
      * a human readable format and display using 
      * functions:  convert_time_to_string() and 
      * display_event_time()
      * 
      * scroll down further to the end of this source to see all our raw data variables
     */
     echo "<h4>Moon</h4>";
     //set the event title:
     $event = sprintf("rise =");
     //call function to display event and time
     display_event_time($moonrise, $event);
     $event = sprintf("transit =");
     display_event_time($moontransit, $event);
     $event = sprintf("set =");
     display_event_time($moonset, $event);
     echo "<br>Phase is {$PhaseName}, ";
     $illumin = $illumin * 100;
     echo round($illumin, 1);
     echo "% illuminated, ";
     echo round($moonage, 1);
     echo " days since new.";
     echo "<h4>Sun</h4>";
     $event = sprintf("rise = ");
     display_event_time($sunrise, $event);
     $event = sprintf("transit =");
     display_event_time($suntransit, $event);
     $event = sprintf("set =");
     display_event_time($sunset, $event);
     echo "<h4> Minor Periods</h4>";
     //display earlier minor time first, minor 1 is based on moonset, minor2 on moonrise
     if (moonrise > moonset) {
         $event = sprintf("");
         display_event_time($minorstart1, $event);
         $event = sprintf(" -");
         display_event_time($minorstop1, $event);
         echo "<br>";
         $event = sprintf("");
         display_event_time($minorstart2, $event);
         $event = sprintf(" -");
         display_event_time($minorstop2, $event);
     } else {
         $event = sprintf("");
         display_event_time($minorstart2, $event);
         $event = sprintf(" -");
         display_event_time($minorstop2, $event);
         echo "<br>";
         $event = sprintf("");
         display_event_time($minorstart1, $event);
         $event = sprintf(" -");
         display_event_time($minorstop1, $event);
     }
     echo "<h4> Major Periods</h4>";
     //display earlier major time first
     if (moontransit < 9.5) {
         $event = sprintf("");
         display_event_time($majorstart1, $event);
         $event = sprintf(" -");
         display_event_time($majorstop1, $event);
         echo "<br>";
         $event = sprintf("");
         display_event_time($majorstart2, $event);
         $event = sprintf(" -");
         display_event_time($majorstop2, $event);
     } else {
         $event = sprintf("");
         display_event_time($majorstart2, $event);
         $event = sprintf(" -");
         display_event_time($majorstop2, $event);
         echo "<br>";
         $event = sprintf("");
         display_event_time($majorstart1, $event);
         $event = sprintf(" -");
         display_event_time($majorstop1, $event);
     }
     echo "<h4>Daily Action Rating</h4>";
     $dayscale = 0;
     $dayscale = $soldayscale + $phasedayscale;
     echo "Todays action is rated a {$dayscale} (scale is 0 thru 5, 5 is the best)";
 }
Exemplo n.º 2
0
$moonunder = get_underfoot($date, $underlong);
/*********************************************************************/
//get solunar minor periods
sol_get_minor1($minorstart1, $minorstop1, $moonrise);
sol_get_minor2($minorstart2, $minorstop2, $moonset);
/*********************************************************************/
//get solunar major periods
sol_get_major1($majorstart1, $majorstop1, $moontransit);
sol_get_major2($majorstart2, $majorstop2, $moonunder);
/*********************************************************************/
//get moon phase
$moonage = get_moon_phase($JD, $PhaseName, $illumin);
/*********************************************************************/
//get day scale
$phasedayscale = phase_day_scale($moonage);
$soldayscale = sol_get_dayscale($moonrise, $moonset, $moontransit, $sunrise, $sunset);
/*********************************************************************/
/* at this point we have raw data times in decimal
 * time format. 
*/
/*********************************************************************/
/*
 * Here is an example on how to convert the results to 
 * a human readable format and display using 
 * functions:  convert_time_to_string() and 
 * display_event_time()
 * 
 * scroll down further to the end of this source to see all our raw data variables
*/
echo "<h4>Moon</h4>";
//set the event title: