function getFailureRatio(ConventionChapter $only = null)
 {
     // complex conditions are difficult to read, but if needed, format such code like
     // a condition below. Please pay attention that predicates are specified
     // at the beginning of each new line in the condition
     if ($this->processor->getTokensNumber() < 1 && sizeof($this->failures) && (Moon::isNotVisible() || 42 != mt_rand(30, 50))) {
         return 1;
     } else {
         // when calling multiple methods with long arguments, form with
         // the results of another calls, use multiple lines and
         // nested indentation
         $ratioCounter = ConventionRatioCounter::create(ConventionRatio::passedToFailed(), $this->processor->getAlgorithm(ConventionTokenizer::recurrent(), $this->convention));
         // multiple setter calls can be merged into one chain if
         // those setters return an object they belong to
         $ratioCounter->setPassed(sizeof($this->failures))->setFailed($this->getFailureNumber($only));
         return $ratioCounter->count();
     }
 }
Ejemplo n.º 2
0
        </div>
    </div>
</div>

<?php 
$sun_info = date_sun_info(strtotime("now"), $lat, $lon);
date_default_timezone_set('America/Santiago');
include "moon.php";
$sunrise = date("H:i", $sun_info['sunrise']);
$sunset = date("H:i", $sun_info['sunset']);
$civil_twilight_begin = date("H:i", $sun_info['civil_twilight_begin']);
$civil_twilight_end = date("H:i", $sun_info['civil_twilight_end']);
$m = date('m');
$d = date('d');
$y = date('Y');
$moon = Moon::calculateMoonTimes($m, $d, $y, $lat, $lon);
$moonrise1 = date("H:i", $moon->moonrise);
$moonrise = date("H:i", strtotime("{$moonrise1} + 1 hours"));
$moonset1 = date("H:i", $moon->moonset);
$moonset = date("H:i", strtotime("{$moonset1} + 1 hours"));
//Calculo de intervalo de horas
function resta($inicio, $fin)
{
    $dif = date("H:i", strtotime("00:00") + strtotime($fin) - strtotime($inicio));
    return $dif;
}
$dur_de_dia = resta($sunrise, $sunset);
$luz_de_dia = resta($civil_twilight_begin, $civil_twilight_end);
if (isset($_SESSION['session'])) {
    ?>
Ejemplo n.º 3
0
 public function attract(Moon $m)
 {
     return "Fly me to the " . $m->getName();
 }
 /**
  * Compute ephemeris.
  *
  * @since    2.0.0
  */
 public function compute()
 {
     $result = array();
     $stations = $this->get_located_stations_list();
     foreach ($stations as $id => $station) {
         $lat = $station['loc_latitude'];
         $lon = $station['loc_longitude'];
         $tz = $station['loc_timezone'];
         $nm = array();
         $nm['device_id'] = $id;
         $nm['device_name'] = $station['device_name'];
         $nm['_id'] = self::get_ephemeris_virtual_id($id);
         $nm['type'] = 'NAEphemer';
         $nm['module_name'] = __('[Ephemeris]', 'live-weather-station');
         $nm['battery_vp'] = 6000;
         $nm['rf_status'] = 0;
         $nm['firmware'] = LWS_VERSION;
         $dashboard = array();
         $dashboard['time_utc'] = time();
         $dashboard['sunrise'] = date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
         $dashboard['sunset'] = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
         try {
             $datetime = new DateTime(date('Y-m-d H:i:s', time()), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $month = $datetime->format('m');
             $day = $datetime->format('d');
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise = $moon->moonrise;
             $moonset = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', time() - 86400), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise_yesterday = $moon->moonrise;
             $moonset_yesterday = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', time() + 86400), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise_tomorrow = $moon->moonrise;
             $moonset_tomorrow = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonrise_yesterday), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonrise = $moonrise_yesterday;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonset_yesterday), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonset = $moonset_yesterday;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonrise_tomorrow), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonrise = $moonrise_tomorrow;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonset_tomorrow), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonset = $moonset_tomorrow;
             }
             $dashboard['moonrise'] = $moonrise;
             $dashboard['moonset'] = $moonset;
         } catch (Exception $ex) {
             $dashboard['moonrise'] = -9999;
             $dashboard['moonset'] = -9999;
         }
         try {
             $moon_phase = new MoonPhase();
             $dashboard['moon_age'] = round($moon_phase->age(), 3);
             $dashboard['moon_phase'] = round($moon_phase->phase(), 4);
             $dashboard['moon_illumination'] = round($moon_phase->illumination() * 100);
             $dashboard['moon_distance'] = round($moon_phase->distance());
             $dashboard['moon_diameter'] = round($moon_phase->diameter(), 9);
             $dashboard['sun_distance'] = round($moon_phase->sundistance());
             $dashboard['sun_diameter'] = round($moon_phase->sundiameter(), 9);
         } catch (Exception $ex) {
             $dashboard['moon_age'] = -9999;
             $dashboard['moon_phase'] = -9999;
             $dashboard['moon_illumination'] = -9999;
             $dashboard['moon_distance'] = -9999;
             $dashboard['moon_diameter'] = -9999;
             $dashboard['sun_distance'] = -9999;
             $dashboard['sun_diameter'] = -9999;
         }
         $nm['dashboard_data'] = $dashboard;
         $nm['data_type'] = array('sunrise', 'sunset', 'moonrise', 'moonset', 'moon_age', 'moon_phase', 'moon_illumination', 'moon_distance', 'moon_diameter', 'sun_distance', 'sun_diameter');
         if (count($nm['dashboard_data']) > 0) {
             $result[] = $nm;
         }
     }
     foreach ($result as $data) {
         $this->get_dashboard($data['device_id'], $data['device_name'], $data['_id'], $data['module_name'], $data['type'], $data['data_type'], $data['dashboard_data']);
     }
     return $result;
 }