function hora()
{
    echo "Amanecer: ";
    echo date_sunrise(time()) . "<br>";
    echo "Atardecer: ";
    echo date_sunset(time());
}
示例#2
0
文件: handler.php 项目: Alambos/bot
 function data($msg, $params)
 {
     $arg = funcs::utfToAscii($msg->args);
     if (empty($arg)) {
         $data = time();
     } else {
         $data = calendar::parse_date($arg);
         if (!$data) {
             return new BotMsg('Podana data nie została rozpoznana<br />' . "\n" . '<br />' . "\n" . '<u>Przykłady:</u><br />' . "\n" . 'data<br />' . "\n" . 'data pojutrze<br />' . "\n" . 'data 1.01.2009');
         }
     }
     if (date('d.m.Y') == date('d.m.Y', $data)) {
         $txt = 'Dziś jest ';
     } else {
         $txt = 'Wybrany dzień to ';
     }
     include './data/data/data.php';
     $txt .= self::$dni[date('w', $data)] . ', ' . date('j', $data) . ' ' . self::$miesiace[date('n', $data)] . ' ' . date('Y', $data) . ' r., ' . (date('z', $data) + 1) . ' dzień roku.<br />' . "\n" . '<br />' . "\n";
     $msg->session->setClass('pogoda');
     if (!isset($msg->session->geo)) {
         $geo = array('lon' => '52.25', 'lat' => '21.0');
     } else {
         $geo = $msg->session->geo;
     }
     $txt .= 'Imieniny: ' . $imieniny[date('n', $data)][date('j', $data)] . '<br />' . "\n" . 'Wschód Słońca: ' . date_sunrise($data, SUNFUNCS_RET_STRING, $geo['lat'], $geo['lon'], 90.58, 1 + date('I')) . '<br />' . "\n" . 'Zachód Słońca: ' . date_sunset($data, SUNFUNCS_RET_STRING, $geo['lat'], $geo['lon'], 90.58, 1 + date('I'));
     return new BotMsg($txt);
 }
示例#3
0
/**
 * Calculate local sunset time for a timestamp, using system-wide location.
 */
function local_sunset_for_date($date)
{
    if (!is_numeric($date)) {
        $date = strtotime($date);
    }
    /*
     * value of 90 degrees 50 minutes is the angle at which
     * the sun is below the horizon.  This is the official
     * sunset time.  Do not use "civil twilight" zenith
     * value of 96 degrees. It's normally about 30 minutes
     * later in the evening than official sunset, and there
     * is some light until then, but it's too dark for safe
     * play.
     */
    $zenith = 90 + 50 / 60;
    /* TODO: eventually, use field's actual location rather than a
     *       system-wide location?  This would be more correct in cities
     *       with a large east/west spread, but might be confusing to some
     */
    $lat = (double) Configure::read('organization.latitude');
    $long = (double) Configure::read('organization.longitude');
    $end_timestamp = date_sunset($date, SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith, date('Z') / 3600);
    // Round down to nearest 5 minutes, and adjust for server location
    $end_timestamp = floor($end_timestamp / 300) * 300 - Configure::read('timezone.adjust') * 60;
    return date('H:i:s', $end_timestamp);
}
示例#4
0
function getSunset($m = true)
{
    $d = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $GLOBALS['config']['geo']['lat'], $GLOBALS['config']['geo']['long'], $GLOBALS['config']['geo']['zenith'], timeZoneOffset());
    if ($m) {
        $d = dateToMinutes($d);
    }
    return $d;
}
 /**
  * @Route("/vychod-a-zapad-slunce/{when}", name="sunrise_and_sunset", defaults={"when"="0"}, requirements={"when"="\d+"})
  * @Template()
  */
 public function sunriseAndSunsetAction($when)
 {
     $date = new \DateTime();
     $date->add(new \DateInterval("P" . $when . "D"));
     date_default_timezone_set("Europe/Prague");
     $sunrise = date_sunrise($date->getTimestamp(), SUNFUNCS_RET_STRING, 50.0872, 14.4211);
     $sunset = date_sunset($date->getTimestamp(), SUNFUNCS_RET_STRING, 50.0872, 14.4211);
     return ['sunrise' => $sunrise, 'sunset' => $sunset, 'date' => $date];
 }
示例#6
0
 /**
  * @param float $latitude
  * @param float $longitude
  * @param int $zenith
  * @param int $gmt
  * @return Sunrise
  * Defaults to Perth, Western Australia
  */
 public static function sunrise($selection = 'perth', $zenith = 90 + 50 / 60)
 {
     $latitude = self::$coordinates[$selection][0];
     $longitude = self::$coordinates[$selection][1];
     $gmt = self::$coordinates[$selection][2];
     $sunrise = date_sunrise(time(), SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt);
     $sunset = date_sunset(time(), SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt);
     return new Sunrise($latitude, $longitude, $zenith, $gmt, "Perth", $sunrise, $sunset);
 }
示例#7
0
 /**
  * @param int $timestamp
  * @param \League\Geotools\Coordinate\CoordinateInterface $coordinate
  * @param int $offset
  * @return \Runalyze\Calculation\NightDetector $this-reference
  * @throws \InvalidArgumentException
  */
 public function setFrom($timestamp, CoordinateInterface $coordinate, $offset = 0)
 {
     if (!is_numeric($timestamp)) {
         throw new \InvalidArgumentException('Provided timestamp must be numerical.');
     }
     $isAfterSunset = $timestamp > date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, $coordinate->getLatitude(), $coordinate->getLongitude(), self::ZENITH, $offset);
     $isBeforeSunrise = $timestamp < date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, $coordinate->getLatitude(), $coordinate->getLongitude(), self::ZENITH, $offset);
     $this->Value = $isAfterSunset || $isBeforeSunrise;
     return $this;
 }
示例#8
0
/**
 * Function to highlight when a generation meter has power readings of zero
 * over the last day despite decent sol_rad figures (>DECENT_SOLRAD_LIMIT W/m2).
 * It looks at each half-hourly measurement.
 *
 * @param resource $becDB
 * @return boolean TRUE if any unexpected zero generation periods seen
 */
function zeroPowerYesterday(&$becDB)
{
    global $verbose, $graphsEnabled;
    // TODO: Tune this value to remove false hits; we wouldn't expect any power
    // output when it's really dim...
    define('DECENT_SOLRAD_LIMIT', 30);
    $dateTime = getYesterdayDateTime();
    $sql = "SELECT power.*,\n                   weather_filton.sol_rad AS sol_rad_filton,\n                   create_centre_meteo_raw.sol_rad AS sol_rad_cc\n            FROM power\n                LEFT JOIN weather_filton ON power.datetime = weather_filton.datetime\n                LEFT JOIN create_centre_meteo_raw ON power.datetime = create_centre_meteo_raw.datetime\n            WHERE (weather_filton.sol_rad > " . DECENT_SOLRAD_LIMIT . " OR\n                  create_centre_meteo_raw.sol_rad > " . DECENT_SOLRAD_LIMIT . ") AND\n                  DATE(power.datetime) = " . sqlDateString($dateTime);
    $result = $becDB->fetchQuery($sql);
    // Work out when sunrise and sunset are - we'll ignore any zero power readings close to them
    $timestamp = $dateTime->getTimestamp();
    $sunriseTime = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, FORECAST_IO_LAT, FORECAST_IO_LONG);
    $sunsetTime = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, FORECAST_IO_LAT, FORECAST_IO_LONG);
    $ignoreWithin = 60 * 60;
    // One hour
    $anyHits = FALSE;
    foreach ($result as $entry) {
        $zeroMeterCount = 0;
        foreach ($becDB->getGenMeterArray() as $genMeter) {
            $dateTime = new DateTime($entry['datetime']);
            $timestamp = $dateTime->getTimestamp();
            # Note: The === below is necessary as otherwise NULL/uninitialised data would also match
            if ($entry[$genMeter] === 0 && $timestamp > $sunriseTime + $ignoreWithin && $timestamp < $sunsetTime - $ignoreWithin) {
                if (!$anyHits) {
                    $anyHits = TRUE;
                    ReportLog::append('Unexpected zero power output during ' . $dateTime->format('d/m/Y') . ":\n");
                    ReportLog::setError(TRUE);
                }
                if ($zeroMeterCount == 0) {
                    ReportLog::append('  Period ending [' . $dateTime->format('H:i') . " (UTC)]\tSolar radiation [CC: " . $entry['sol_rad_cc'] . ' Filton: ' . $entry['sol_rad_filton'] . "]: {$genMeter}");
                    $zeroMeterCount++;
                } else {
                    ReportLog::append(', ' . $genMeter);
                    $zeroMeterCount++;
                }
            }
        }
        if ($zeroMeterCount) {
            ReportLog::append("\n");
        }
    }
    if ($anyHits) {
        ReportLog::append("\n\n");
    } else {
        ReportLog::append('No unexpected zero power output readings yesterday (' . $dateTime->format('d/m/Y') . ")\n\n");
    }
    return $anyHits;
}
 /**
  * Return true, false or null depending on whether the [opening hours]
  * value explicitly indicates an open, closed or undecided result.
  *
  * @param double $time A numeric value representing a time. If null, the
  *                     current time is used.
  *
  * @link   http://wiki.openstreetmap.org/wiki/Key:opening_hours
  * @return null|boolean
  */
 public function isOpen($time = null)
 {
     if ($this->value === null) {
         return null;
     }
     if ($this->value === '24/7') {
         return true;
     }
     if ($time === null) {
         $time = time();
     }
     if ($this->value === 'sunrise-sunset') {
         $start = $this->_startTime(date_sunrise($time));
         $end = $this->_endTime(date_sunset($time));
         $d = getdate($time);
         $ctime = $d['hours'] * 60 + $d['minutes'];
         return $ctime >= $start && $ctime <= $end;
     }
     // other simple test would be sunrise-sunset - with
     // offsets that would need to be taken into account
     // time specs...
     $rule_sequences = explode(';', $this->value);
     $day = strtolower(substr(date('D', $time), 0, 2));
     $retval = false;
     foreach ($rule_sequences as $rule_sequence) {
         $rule_sequence = strtolower(trim($rule_sequence));
         // If the day is explicitly specified in the rule sequence then
         // processing it takes precedence.
         if (preg_match('/' . $day . '/', $rule_sequence)) {
             // @fixme: brittle. use preg_replace with \w
             $portions = explode(' ', str_replace(', ', ',', $rule_sequence));
             return $this->_openTimeSpec($portions, $time);
         }
         // @fixme: brittle. use preg_replace with \w
         $portions = explode(' ', str_replace(', ', ',', $rule_sequence));
         $open = $this->_openTimeSpec($portions, $time);
         if ($open) {
             $retval = true;
         } elseif ($open === false) {
             $retval = false;
         }
     }
     return $retval;
 }
示例#10
0
文件: Weather.php 项目: aaronpk/Atlas
 private static function _sunny($lat, $lng, $timezone)
 {
     // Get the beginning of the current day
     $now = new DateTime();
     if ($timezone) {
         $now->setTimeZone(new DateTimeZone($timezone));
     }
     $now->setTime(0, 0, 0);
     $now = $now->format('U');
     if ($lat !== null) {
         $sunrise = date_sunrise($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lng, 96);
         $sunset = date_sunset($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lng, 92);
         if ($sunrise < time() && time() < $sunset) {
             return 'day';
         } else {
             return 'night';
         }
     } else {
         return 'unknown';
     }
 }
示例#11
0
 public function getForecast($latitude, $longitude, $units)
 {
     $response = array("response_message" => array("type" => "RESPONSE", "name" => "WEATHER_FORECAST", "data" => array()));
     $url = self::API_ENDPOINT . self::API_KEY . '/';
     $url .= $latitude . ',' . $longitude . '?units=' . $units;
     $forecast = file_get_contents($url);
     //print_r($http_response_header);
     if (isset($http_response_header) && strpos($http_response_header[0], '200')) {
         $forecast = (array) json_decode($forecast, true);
         $time = $forecast["currently"]["time"];
         //timestamp del a salida del sol.
         $sunrise_timestamp = date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $forecast['latitude'], $forecast['longitude']);
         $sunset_timestamp = date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $forecast['latitude'], $forecast['longitude']);
         //print_r($forecast);
         $forecast['currently']['sunrise_timestamp'] = $sunrise_timestamp;
         $forecast['currently']['sunset_timestamp'] = $sunset_timestamp;
         $response["response_message"]["data"] = array("error" => false, "msg" => array("forecast" => $forecast));
     } else {
         $response["response_message"]["data"] = array("error" => true, "msg" => array("msg" => "La previsión no se pudo obtener"));
     }
     return $response;
 }
示例#12
0
 /**
  * @param hcal_datetime $dt
  */
 public function __construct($dt)
 {
     $this->datetime = $dt;
     // $heb_date, $ts, $gmt_offset, $location, $now, $datetime =  null
     $ts = $dt->get_ts(false);
     $this->is_dst = false;
     $tz_offset = $dt->get_timezone_offset($this->is_dst);
     $ts -= $tz_offset;
     $this->gmt_offset = $tz_offset / 3600.0;
     $this->now = $dt->s / 3600.0 + $dt->m / 60.0 + $dt->h;
     $zenith = 90.0 + 50.0 / 60;
     $this->heb_date = $dt->get_hebrew_date_numeric();
     $this->location = $dt->location;
     $this->data = array();
     $lat = $this->location->latitude;
     $long = $this->location->longitude;
     $sunrise = date_sunrise($ts, SUNFUNCS_RET_DOUBLE, $lat, $long, $zenith, $this->gmt_offset);
     $sunset = date_sunset($ts, SUNFUNCS_RET_DOUBLE, $lat, $long, $zenith, $this->gmt_offset);
     $this->sunrise = $sunrise;
     $this->sunset = $sunset;
     $this->rel_hr = ($sunset - $sunrise) / 12.0;
     $this->is_chul = (bool) @$this->location->data['chul'];
     $this->calculate_base_times();
 }
function getSunset($format)
{
    global $schedulePars;
    return date_sunset(time(), $format, $schedulePars[SCHEDULE_LATITUDE], $schedulePars[SCHEDULE_LONGTITUDE], SCHEDULE_ZENITH, getTimeOffset());
}
示例#14
0
// if ( isset($debug) ) {
if ($debug) {
    echo "dateTimeUTC: ";
    print_r($dateTimeUTC);
    //	echo "something: $something\n";
    echo "dateOff: {$dateOff}\n";
}
//offical = 90 degrees 50' 90.8333 (gk: this is the "official" number to determine sunrise & sunset)
//civil = 96 degrees (gk: this is the number to obtain civilian twilight times - horizon may be visible)
//nautical = 102 degrees (gk: this is the number to obtain nautical twilight - the horizon is not visible)
//astronomical = 108 degrees (gk: this is the number for astronomical twilight - starts at sunset).
//$zenith = 108;
// Higher is sooner sunrise
//$zenithRise = 96;
$zenithRise = 102;
// Higher is later sunset
//$zenithSet = 96;
$zenithSet = 102;
$sunrise = date_sunrise($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenithRise, $hours);
$sunset = date_sunset($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenithSet, $hours);
echo "Sunrise: " . $sunrise . "\n";
echo "Sunset: " . $sunset . "\n";
if (isset($doPretty)) {
    $nowPretty = date('Y-m-d g:i:sa', $now);
    $sunrisePretty = date('Y-m-d g:i:sa', $sunrise);
    $sunsetPretty = date('Y-m-d g:i:sa', $sunset);
    echo "now: {$now}\n";
    echo "nowPretty: {$nowPretty}\n";
    echo "sunrisePretty: {$sunrisePretty}\n";
    echo "sunsetPretty: {$sunsetPretty}\n";
}
示例#15
0
	<h1>When should Marty hunt?</h1>
	

	<?php 
/* calculate the sunrise time for Lisbon, Portugal
	 Latitude: 47.4736 North
	 Longitude: 94.8803 West
	 Zenith ~= 90
	 timezone: GMT -06
	 */
date_default_timezone_set('America/Chicago');
//print "Today is ";
//print date("D, M j G:i:s T Y");
print "<br />Current Time is: ";
print date("g:i A");
//print "Sunrei"
//print date_sunrise( time(), SUNFUNCS_RET_STRING,47.4736,94.8803,90,-06);
print "<br />Sunrise time : ";
print date("g: i A", date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -06));
print "<br /> Start Hunting at: ";
print date("g:i A", date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -06) - 1800);
print "<br/> Sunset Time: ";
print date("g:i A", date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -6));
print "<br/> Stop hunting at: ";
print date("g:i A", date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -6) + 1800);
?>
	
</body>

</html>
<?php

$taskLocation = realpath(dirname(__FILE__));
chdir($taskLocation);
include "../config.php";
$file = file_get_contents("templates/metrogram-template.xml");
date_default_timezone_set(TZ);
if (date('I')) {
    $file = str_replace("[--UTCOFFSET--]", 60, $file);
} else {
    $file = str_replace("[--UTCOFFSET--]", 0, $file);
}
$file = str_replace("[--sunrise--]", Date("Y-m-d") . "T" . date_sunrise(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90 + 60 / 60, 0) . ":00", $file);
$file = str_replace("[--sunset--]", Date("Y-m-d") . "T" . date_sunset(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90, 0) . ":00", $file);
$file = str_replace("[--LAT--]", LAT, $file);
$file = str_replace("[--LONG--]", LONG, $file);
$file = str_replace("[--ALTITUDE--]", ALTITUDE, $file);
$link = mysql_connect(SERVER, USER, PASSWORD);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_found = mysql_select_db(DATABASE);
$sql = "SELECT * FROM Weather.meteogram\nWHERE `from` >= now() - INTERVAL 48 HOUR GROUP BY hour(`from`) ORDER BY `from` DESC;";
$query = mysql_query($sql);
$tabularContent = "";
$rowtemplate = file_get_contents("templates/metrogram-rowdata-template.xml");
while ($r = mysql_fetch_array($query)) {
    $rowdata = $rowtemplate;
    $rowdata = str_replace("[--precipitation--]", $r['precipitation'], $rowdata);
    $rowdata = str_replace("[--deg--]", $r['deg'], $rowdata);
    $rowdata = str_replace("[--code--]", $r['code'], $rowdata);
示例#17
0
<?php 
//Calculate the sunrise time for Brazil, Sao Paulo
//Latitude: 23.533773 South
//Longitude: 46.625290 West
//Zenith ~= 90
//offset: +1 GMT
echo "<h2>America, Brazil (Sao Paulo city) </h2>";
echo "Date: " . date("M d Y");
echo "<br>Sunrise time: ";
echo date_sunrise(time(), SUNFUNCS_RET_STRING, 23.5, -9, 90, 1);
echo "<br>Sunset time: ";
echo date_sunset(time(), SUNFUNCS_RET_STRING, 46.6, -9, 90, 1);
echo "<br>";
date_default_timezone_set('America/Sao_Paulo');
echo "The current tme is " . date("h:i:sa");
示例#18
0
function GetSkymning()
{
    connectdb();
    $sql = "SELECT * from settings WHERE label=longitud";
    $result = mysql_query($sql);
    $longitud = mysql_result($result, "value");
    $sql = "SELECT * from settings WHERE label=latitud";
    $result = mysql_query($sql);
    $latitud = mysql_result($result, "latitud");
    $sql = "SELECT * from settings WHERE label=tidzon";
    $result = mysql_query($sql);
    $timezone = mysql_result($result, "value");
    $zenith = 90 + 50 / 60;
    $twilightZenith = 96;
    $timezone = 1;
    $time = date_sunset(time(), SUNFUNCS_RET_STRING, $latitud, $longitud, $twilightZenith, $timezone);
    return $time;
}
<?php

$taskLocation = realpath(dirname(__FILE__));
chdir($taskLocation);
include "../config.php";
$meteogram = array('location' => array('name' => 'Scampton', 'type' => 'Town', 'country' => "United Kingdom", 'timezone' => array('@attributes' => array('id' => "Europe/London", 'utcoffsetMinutes' => "0")), 'location' => array('@attributes' => array('altitude' => "", 'latitude' => "", 'longitude' => "", 'geobase' => "geonames", 'geobaseid' => "2643743"))), 'credit' => array('comment' => array("", ""), 'link' => array("@attributes" => array("text" => "Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK", "url" => "http://www.yr.no/place/United_Kingdom/England/London/"))), 'links' => array('link' => array(array('@attributes' => array('id' => "xmlSource", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/forecast.xml")), array('@attributes' => array('id' => "xmlSourceHourByHour", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/forecast_hour_by_hour.xml")), array('@attributes' => array('id' => "hourByHour", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/hour_by_hour")), array('@attributes' => array('id' => "overview", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/")), array('@attributes' => array('id' => "longTermForecast", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/long")))), 'meta' => array('lastupdate' => "", 'nextupdate' => ""), 'sun' => array("@attributes" => array('rise' => "", 'set' => "")), 'forecast' => array('tabular' => array('time' => array())));
date_default_timezone_set(TZ);
if (date('I')) {
    $meteogram['location']['timezone']['@attributes']['utcoffsetMinutes'] = "60";
}
$meteogram['meta']['lastupdate'] = Date("Y-m-d\\TH:m:s");
$meteogram['meta']['nextupdate'] = Date("Y-m-d\\TH:m:s");
$meteogram['sun']['@attributes']['rise'] = Date("Y-m-d") . "T" . date_sunrise(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90 + 60 / 60, 0);
$meteogram['sun']['@attributes']['set'] = Date("Y-m-d") . "T" . date_sunset(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90, 0);
$meteogram['location']['location']['@attributes']['altitude'] = ALTITUDE;
$meteogram['location']['location']['@attributes']['latitude'] = LAT;
$meteogram['location']['location']['@attributes']['longitude'] = LONG;
//die($meteogram['location']['timezone'] ['@attributes']);
$meteogram['location']['timezone']['@attributes']['id'] = TZ;
$link = mysql_connect(SERVER, USER, PASSWORD);
$db_found = mysql_select_db(DATABASE);
$sql = "SELECT * FROM Weather.meteogram " . "WHERE `from` >= now() - INTERVAL 49 HOUR GROUP BY DATE_FORMAT(`from`, \"%d-%m-%y %H:00\");";
$query = mysql_query($sql);
$tabularContent = "";
$time = array(['@attributes'] => array(['from'] => "0", ['to'] => "0"), ['comment'] => array(), ['symbol'] => array(['@attributes'] => array(['number'] => "2", ['numberEx'] => "02", ['name'] => "Fair", ['var'] => "02d")), ['precipitation'] => array(['@attributes'] => array(['value'] => "0")), ['windDirection'] => array(['@attributes'] => array(['deg'] => "0", ['code'] => "0", ['name'] => "0")), ['windSpeed'] => array(['@attributes'] => array(['mps'] => "0", ['name'] => "")), ['temperature'] => array(['@attributes'] => array(['unit'] => "celcius", ['value'] => "0")), ['pressure'] => array(['@attributes'] => array(['unit'] => "hPa", ['value'] => "0")));
while ($r = mysql_fetch_array($query)) {
    $time['@attributes']['from'] = $r['from'];
    $time['@attributes']['to'] = $r['to'];
    $time['comment'] = array("", "");
    $time['symbol']['@attributes']['number'] = "";
    $time['symbol']['@attributes']['numberEx'] = "";
示例#20
0
 /**
  * Calculates sunrise and sunset for a location
  *
  * The sun position algorithm taken from the 'US Naval Observatory's
  * Almanac for Computers', implemented by Ken Bloom <kekabloom[at]ucdavis[dot]edu>
  * for the zmanim project, converted to C by Moshe Doron <mosdoron[at]netvision[dot]net[dot]il>
  * and finally taken from the PHP5 sources and converted to native PHP as a wrapper.
  *
  * The date has to be entered as a timestamp!
  *
  * @param   int                         $date
  * @param   int                         $retformat
  * @param   float                       $latitude
  * @param   float                       $longitude
  * @param   float                       $zenith
  * @param   float                       $gmt_offset
  * @param   bool                        $sunrise
  * @return  PEAR_Error|mixed
  * @throws  PEAR_Error::SERVICES_WEATHER_ERROR_SUNFUNCS_DATE_INVALID
  * @throws  PEAR_Error::SERVICES_WEATHER_ERROR_SUNFUNCS_RETFORM_INVALID
  * @throws  PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_ERROR
  * @access  public
  */
 function calculateSunRiseSet($date, $retformat = null, $latitude = null, $longitude = null, $zenith = null, $gmt_offset = null, $sunrise = true)
 {
     // Date must be timestamp for now
     if (!is_int($date)) {
         return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_SUNFUNCS_DATE_INVALID, __FILE__, __LINE__);
     }
     // Check for proper return format
     if ($retformat === null) {
         $retformat = SUNFUNCS_RET_STRING;
     } elseif (!in_array($retformat, array(SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, SUNFUNCS_RET_DOUBLE))) {
         return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_SUNFUNCS_RETFORM_INVALID, __FILE__, __LINE__);
     }
     // Set default values for coordinates
     if ($latitude === null) {
         $latitude = SUNFUNCS_DEFAULT_LATITUDE;
     } else {
         $latitude = (double) $latitude;
     }
     if ($longitude === null) {
         $longitude = SUNFUNCS_DEFAULT_LONGITUDE;
     } else {
         $longitude = (double) $longitude;
     }
     if ($zenith === null) {
         if ($sunrise) {
             $zenith = SUNFUNCS_SUNRISE_ZENITH;
         } else {
             $zenith = SUNFUNCS_SUNSET_ZENITH;
         }
     } else {
         $zenith = (double) $zenith;
     }
     // Default value for GMT offset
     if ($gmt_offset === null) {
         $gmt_offset = date("Z", $date) / 3600;
     } else {
         $gmt_offset = (double) $gmt_offset;
     }
     // If we have PHP5, then act as wrapper for the appropriate functions
     if ($sunrise && function_exists("date_sunrise")) {
         return date_sunrise($date, $retformat, $latitude, $longitude, $zenith, $gmt_offset);
     }
     if (!$sunrise && function_exists("date_sunset")) {
         return date_sunset($date, $retformat, $latitude, $longitude, $zenith, $gmt_offset);
     }
     // Apparently we have PHP4, so calculate the neccessary steps in native PHP
     // Step 1: First calculate the day of the year
     $N = date("z", $date) + 1;
     // Step 2: Convert the longitude to hour value and calculate an approximate time
     $lngHour = $longitude / 15;
     // Use 18 for sunset instead of 6
     if ($sunrise) {
         // Sunrise
         $t = $N + (6 - $lngHour) / 24;
     } else {
         // Sunset
         $t = $N + (18 - $lngHour) / 24;
     }
     // Step 3: Calculate the sun's mean anomaly
     $M = 0.9856 * $t - 3.289;
     // Step 4: Calculate the sun's true longitude
     $L = $M + 1.916 * sin(deg2rad($M)) + 0.02 * sin(deg2rad(2 * $M)) + 282.634;
     while ($L < 0) {
         $Lx = $L + 360;
         assert($Lx != $L);
         // askingtheguru: really needed?
         $L = $Lx;
     }
     while ($L >= 360) {
         $Lx = $L - 360;
         assert($Lx != $L);
         // askingtheguru: really needed?
         $L = $Lx;
     }
     // Step 5a: Calculate the sun's right ascension
     $RA = rad2deg(atan(0.91764 * tan(deg2rad($L))));
     while ($RA < 0) {
         $RAx = $RA + 360;
         assert($RAx != $RA);
         // askingtheguru: really needed?
         $RA = $RAx;
     }
     while ($RA >= 360) {
         $RAx = $RA - 360;
         assert($RAx != $RA);
         // askingtheguru: really needed?
         $RA = $RAx;
     }
     // Step 5b: Right ascension value needs to be in the same quadrant as L
     $Lquadrant = floor($L / 90) * 90;
     $RAquadrant = floor($RA / 90) * 90;
     $RA = $RA + ($Lquadrant - $RAquadrant);
     // Step 5c: Right ascension value needs to be converted into hours
     $RA /= 15;
     // Step 6: Calculate the sun's declination
     $sinDec = 0.39782 * sin(deg2rad($L));
     $cosDec = cos(asin($sinDec));
     // Step 7a: Calculate the sun's local hour angle
     $cosH = (cos(deg2rad($zenith)) - $sinDec * sin(deg2rad($latitude))) / ($cosDec * cos(deg2rad($latitude)));
     // XXX: What's the use of this block.. ?
     // if (sunrise && cosH > 1 || !sunrise && cosH < -1) {
     //     throw doesnthappen();
     // }
     // Step 7b: Finish calculating H and convert into hours
     if ($sunrise) {
         // Sunrise
         $H = 360 - rad2deg(acos($cosH));
     } else {
         // Sunset
         $H = rad2deg(acos($cosH));
     }
     $H = $H / 15;
     // Step 8: Calculate local mean time
     $T = $H + $RA - 0.06571 * $t - 6.622;
     // Step 9: Convert to UTC
     $UT = $T - $lngHour;
     while ($UT < 0) {
         $UTx = $UT + 24;
         assert($UTx != $UT);
         // askingtheguru: really needed?
         $UT = $UTx;
     }
     while ($UT >= 24) {
         $UTx = $UT - 24;
         assert($UTx != $UT);
         // askingtheguru: really needed?
         $UT = $UTx;
     }
     $UT = $UT + $gmt_offset;
     // Now bring the result into the chosen format and return
     switch ($retformat) {
         case SUNFUNCS_RET_TIMESTAMP:
             return intval($date - $date % (24 * 3600) + 3600 * $UT);
         case SUNFUNCS_RET_STRING:
             $N = floor($UT);
             return sprintf("%02d:%02d", $N, floor(60 * ($UT - $N)));
         case SUNFUNCS_RET_DOUBLE:
             return $UT;
         default:
             return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_UNKNOWN_ERROR, __FILE__, __LINE__);
     }
 }
示例#21
0
<?php

/* Prototype  : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
 * Description: Returns time of sunset for a given day and location 
 * Source code: ext/date/php_date.c
 * Alias to functions: 
 */
echo "*** Testing date_sunset() : error conditions ***\n";
//Initialise the variables
$time = time();
$latitude = 38.4;
$longitude = -9;
$zenith = 90;
$gmt_offset = 1;
$extra_arg = 10;
// Zero arguments
echo "\n-- Testing date_sunset() function with Zero arguments --\n";
var_dump(date_sunset());
//Test date_sunset with one more than the expected number of arguments
echo "\n-- Testing date_sunset() function with more than expected no. of arguments --\n";
var_dump(date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg));
var_dump(date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg));
var_dump(date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg));
?>
===DONE===
示例#22
0
			</form>
			<?php 
echo '<table>';
echo '<thead>';
echo '<tr>';
echo '</tr>';
echo '</thead>';
if (isset($_POST['latitude']) && isset($_POST['longitude'])) {
    date_default_timezone_set('UTC');
    $lat = $_POST['latitude'];
    $long = $_POST['longitude'];
    $now = time();
    echo '<div>' . date_sunrise($now, SUNFUNCS_RET_STRING, $lat, $long) . '</div>';
    echo '<div>' . date_sunset($now, SUNFUNCS_RET_STRING, $lat, $long) . '</div>';
    for ($day = 0; $day <= 6; $day++) {
        echo '<tr>';
        $timestamp = $now + $day * 86400;
        $row = array();
        $row[] = date('M d', $timestamp);
        $row[] = date_sunrise($timestamp, SUNFUNCS_RET_STRING, $lat, $long, 97.5);
        $row[] = date_sunrise($timestamp, SUNFUNCS_RET_STRING, $lat, $long);
        $row[] = date_sunset($timestamp, SUNFUNCS_RET_STRING, $lat, $long);
        $row[] = date_sunset($timestamp, SUNFUNCS_RET_STRING, $lat, $long, 97.5);
        echo '<td>' . implode('</td><td>', $row) . '</td>';
        echo '</tr>';
    }
}
echo '</table>';
?>
        </body>
</html>
示例#23
0
function yrno_date_line($time)
{
    global $latitude, $longitude, $rowColor, $timeFormat, $imgDir, $srise, $sset, $cols;
    $srise = date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude);
    // standard time integer
    $sset = date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude);
    $dlength = $sset - $srise;
    $dlengthHr = floor($dlength / 3600);
    $dlengthMin = round(($dlength - 3600 * $dlengthHr) / 60);
    $strDayLength = $dlengthHr . ':' . substr('00' . $dlengthMin, -2);
    $longDate = yrno_long_date($time);
    $string = '<tr class="dateline ' . $rowColor . '"><td colspan="' . $cols . '">
<span style="float:left; position:relative;">&nbsp;<b>' . $longDate . '</b></span>
<span style="float:right;position:relative;">
	<span class="rTxt">
		<img src="' . $imgDir . '/sunrise.png" width="24" height="12" alt="sunrise" />&nbsp;&nbsp;' . date($timeFormat, $srise) . '&nbsp;&nbsp;
		<img src="' . $imgDir . '/sunset.png"  width="24" height="12" alt="sunset" />&nbsp;&nbsp;' . date($timeFormat, $sset) . '&nbsp;&nbsp;&nbsp;' . yrnotransstr('Daylength') . ': ' . $strDayLength . '&nbsp;
	</span>
</span>
</td></tr>' . PHP_EOL;
    if ($rowColor == 'row-dark') {
        $rowColor = 'row-light';
    } else {
        $rowColor = 'row-dark';
    }
    return $string;
}
示例#24
0
 /**
  * Returns sunset time
  * @param float $latitude
  * @param float $longitude
  * @param null|int $timestamp If not set, current timestamp will be used.
  * @param null|int $gmtOffset If not set, current GMT offset will be used.
  * @static
  * @return string
  */
 public static function getSunsetTime($latitude, $longitude, $timestamp = null, $gmtOffset = null)
 {
     if ($timestamp === null) {
         $timestamp = time();
     }
     if ($gmtOffset === null) {
         $gmtOffset = self::getGmtOffset();
     }
     return date_sunset($timestamp, SUNFUNCS_RET_STRING, $latitude, $longitude, ini_get('date.sunrise_zenith'), $gmtOffset);
 }
示例#25
0
<?php

date_default_timezone_set('Asia/Jerusalem');
for ($a = 1; $a <= 12; $a++) {
    echo date_sunrise(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_TIMESTAMP, 31.7667, 35.2333, 90.83, 2) . " ";
    echo date_sunrise(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_STRING, 31.7667, 35.2333, 90.83, 2) . " ";
    echo date_sunrise(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_DOUBLE, 31.7667, 35.2333, 90.83, 2) . "\n";
    echo date_sunset(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_TIMESTAMP, 31.7667, 35.2333, 90.83, 2) . " ";
    echo date_sunset(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_STRING, 31.7667, 35.2333, 90.83, 2) . " ";
    echo date_sunset(mktime(1, 1, 1, $a, 1, 2003), SUNFUNCS_RET_DOUBLE, 31.7667, 35.2333, 90.83, 2) . "\n";
}
示例#26
0
<?php

$tzOffset = date('O') / 100;
?>
<pre>
  Date: <?php 
echo date('Y-m-d H:i');
?>
 
  UTC Offset: <?php 
echo $tzOffset;
?>
 
  Sunset: <?php 
echo date_sunset(time(), SUNFUNCS_RET_STRING, $GLOBALS['config']['geo']['lat'], $GLOBALS['config']['geo']['long'], $GLOBALS['config']['geo']['zenith'], $tzOffset);
?>
 
  Sunrise: <?php 
echo date_sunrise(time(), SUNFUNCS_RET_STRING, $GLOBALS['config']['geo']['lat'], $GLOBALS['config']['geo']['long'], $GLOBALS['config']['geo']['zenith'], $tzOffset);
?>
 

</pre>
示例#27
0
 /**
  * Calculates the sunrise or sunset based on a location
  *
  * @param  array  $location  Location for calculation MUST include 'latitude', 'longitude', 'horizon'
  * @param  bool   $horizon   true: sunrise; false: sunset
  * @return mixed  - false: midnight sun, integer:
  */
 protected function calcSun($location, $horizon, $rise = false)
 {
     // timestamp within 32bit
     if (abs($this->_unixTimestamp) <= 0x7fffffff) {
         if ($rise === false) {
             return date_sunset($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'], $location['longitude'], 90 + $horizon, $this->_offset / 3600);
         }
         return date_sunrise($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'], $location['longitude'], 90 + $horizon, $this->_offset / 3600);
     }
     // self calculation - timestamp bigger than 32bit
     // fix circle values
     $quarterCircle = 0.5 * M_PI;
     $halfCircle = M_PI;
     $threeQuarterCircle = 1.5 * M_PI;
     $fullCircle = 2 * M_PI;
     // radiant conversion for coordinates
     $radLatitude = $location['latitude'] * $halfCircle / 180;
     $radLongitude = $location['longitude'] * $halfCircle / 180;
     // get solar coordinates
     $tmpRise = $rise ? $quarterCircle : $threeQuarterCircle;
     $radDay = $this->date('z', $this->_unixTimestamp) + ($tmpRise - $radLongitude) / $fullCircle;
     // solar anomoly and longitude
     $solAnomoly = $radDay * 0.017202 - 0.0574039;
     $solLongitude = $solAnomoly + 0.0334405 * sin($solAnomoly);
     $solLongitude += 4.93289 + 0.000349066 * sin(2 * $solAnomoly);
     // get quadrant
     $solLongitude = $this->_range($solLongitude, $fullCircle);
     if ($solLongitude / $quarterCircle - intval($solLongitude / $quarterCircle) == 0) {
         $solLongitude += 4.84814E-6;
     }
     // solar ascension
     $solAscension = sin($solLongitude) / cos($solLongitude);
     $solAscension = atan2(0.9174600000000001 * $solAscension, 1);
     // adjust quadrant
     if ($solLongitude > $threeQuarterCircle) {
         $solAscension += $fullCircle;
     } else {
         if ($solLongitude > $quarterCircle) {
             $solAscension += $halfCircle;
         }
     }
     // solar declination
     $solDeclination = 0.39782 * sin($solLongitude);
     $solDeclination /= sqrt(-$solDeclination * $solDeclination + 1);
     $solDeclination = atan2($solDeclination, 1);
     $solHorizon = $horizon - sin($solDeclination) * sin($radLatitude);
     $solHorizon /= cos($solDeclination) * cos($radLatitude);
     // midnight sun, always night
     if (abs($solHorizon) > 1) {
         return false;
     }
     $solHorizon /= sqrt(-$solHorizon * $solHorizon + 1);
     $solHorizon = $quarterCircle - atan2($solHorizon, 1);
     if ($rise) {
         $solHorizon = $fullCircle - $solHorizon;
     }
     // time calculation
     $localTime = $solHorizon + $solAscension - 0.0172028 * $radDay - 1.73364;
     $universalTime = $localTime - $radLongitude;
     // determinate quadrant
     $universalTime = $this->_range($universalTime, $fullCircle);
     // radiant to hours
     $universalTime *= 24 / $fullCircle;
     // convert to time
     $hour = intval($universalTime);
     $universalTime = ($universalTime - $hour) * 60;
     $min = intval($universalTime);
     $universalTime = ($universalTime - $min) * 60;
     $sec = intval($universalTime);
     return $this->mktime($hour, $min, $sec, $this->date('m', $this->_unixTimestamp), $this->date('j', $this->_unixTimestamp), $this->date('Y', $this->_unixTimestamp), -1, true);
 }
示例#28
0
/**
 * Calculate local sunset time for a timestamp, using system-wide location.
 */
function local_sunset_for_date($timestamp)
{
    /*
     * value of 90 degrees 50 minutes is the angle at which
     * the sun is below the horizon.  This is the official
     * sunset time.  Do not use "civil twilight" zenith
     * value of 96 degrees. It's normally about 30 minutes
     * later in the evening than official sunset, and there
     * is some light until then, but it's too dark for safe
     * play.
     */
    $zenith = 90 + 50 / 60;
    /* TODO: eventually, use field's actual location rather than a
     *       system-wide location?  This would be more correct in cities
     *       with a large east/west spread, but might be confusing to some
     */
    $lat = variable_get('location_latitude', 45.42102);
    $long = variable_get('location_longitude', -75.69525);
    $end_timestamp = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith, date('Z') / 3600);
    # Round down to nearest 5 minutes
    $end_timestamp = floor($end_timestamp / 300) * 300;
    return strftime('%H:%M', $end_timestamp);
}
示例#29
0
//get an unset variable
$unset_var = 10;
unset($unset_var);
// define some classes
class classWithToString
{
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var);
// loop through each element of the array for format
foreach ($inputs as $key => $value) {
    echo "\n--{$key}--\n";
    var_dump(date_sunset($time, $value, $latitude, $longitude, $zenith, $gmt_offset));
}
?>
===DONE===
示例#30
0
 protected function dashboard_client()
 {
     $this->load->model('project_model', 'project');
     $data['projects'] = $this->project->order_by('created_on', 'DESC')->get_many_by('client_id', $_SESSION['user']['id']);
     if (!empty($data['projects'])) {
         $this->load->model('event_model', 'event');
         $this->load->model('deliverable_model', 'deliverable');
         $this->load->model('event_user_model', 'event_user');
         $data['expense_colors'] = array('rgba(34, 190, 239, 1)', 'rgba(162, 210, 0, 1)', 'rgba(255, 193, 0, 1)', 'rgba(255, 0, 102, 1)');
         foreach ($data['projects'] as $project) {
             $events = $this->event->get_by_project_id($project->id);
             $project->cost = 0;
             $project->events = array();
             $albums_total = 0;
             $albums_ready = 0;
             $photo_services = 0;
             $photo_deliverables = 0;
             $video_services = 0;
             $video_deliverables = 0;
             foreach ($events as $event) {
                 $project->cost += $event->price;
                 $event->rank = 0;
                 $duplicate_count = 0;
                 foreach ($events as $e) {
                     if ($e->id === $event->id) {
                         $event->rank = $duplicate_count + 1;
                     } else {
                         if ($e->event_type === $event->event_type) {
                             $duplicate_count++;
                         }
                     }
                 }
                 $event->rank = $duplicate_count > 0 ? ' ' . $event->rank : '';
                 if (!empty($event->event_status)) {
                     $albums_total++;
                     if ($event->event_status === 'Album Ready') {
                         $albums_ready++;
                     }
                     if (date('Y-m-d') >= date('Y-m-d', strtotime($event->date))) {
                         if ($event->event_status === 'Photos Uploaded') {
                             $event->event_status_html = '<a class="color-' . explode(' ', $this->session->setting['link_color']->value)[0] . '" href="' . base_url('proofs/' . rawurlencode($project->name) . '/' . rawurlencode($event->event_type . $event->rank)) . '">' . $event->event_status . '</a>';
                         } else {
                             if ($event->event_status === 'Layouts Uploaded') {
                                 $event->event_status_html = '<a class="color-' . explode(' ', $this->session->setting['link_color']->value)[0] . '" href="' . base_url('layouts/' . rawurlencode($project->name) . '/' . rawurlencode($event->event_type . $event->rank)) . '">' . $event->event_status . '</a>';
                             } else {
                                 $event->event_status_html = $event->event_status;
                             }
                         }
                     } else {
                         $event->event_status_html = 'Not Covered';
                     }
                 } else {
                     $event->event_status_html = '-';
                 }
                 if (!empty($event->photoshoot_status)) {
                     $albums_total++;
                     if ($event->photoshoot_status === 'Album Ready') {
                         $albums_ready++;
                     }
                     if (date('Y-m-d') >= date("Y-m-d", strtotime($event->date))) {
                         if ($event->photoshoot_status === 'Photos Uploaded') {
                             $event->photoshoot_status_html = '<a class="color-' . explode(' ', $this->session->setting['link_color']->value)[0] . '" href="' . base_url('proofs/' . rawurlencode($project->name) . '/' . rawurlencode($event->event_type . $event->rank . ' Photoshoot')) . '">' . $event->photoshoot_status . '</a>';
                         } else {
                             if ($event->photoshoot_status === 'Layouts Uploaded') {
                                 $event->photoshoot_status_html = '<a class="color-' . explode(' ', $this->session->setting['link_color']->value)[0] . '" href="' . base_url('layouts/' . rawurlencode($project->name) . '/' . rawurlencode($event->event_type . $event->rank . ' Photoshoot')) . '">' . $event->photoshoot_status . '</a>';
                             } else {
                                 $event->photoshoot_status_html = $event->photoshoot_status;
                             }
                         }
                     } else {
                         $event->photoshoot_status_html = 'Best Time - ' . date('h:i A', strtotime(date_sunset(strtotime($event->date), SUNFUNCS_RET_STRING, 33.7294, 73.09310000000001) . ' - 90 minutes'));
                     }
                 } else {
                     $event->photoshoot_status_html = '-';
                 }
                 $deliverables = $this->deliverable->get_by_event_id($event->id);
                 foreach ($deliverables as $deliverable) {
                     if ($deliverable->class === 'Photo' && $deliverable->category === 'Service') {
                         $photo_services += $deliverable->price;
                     } else {
                         if ($deliverable->class === 'Photo' && $deliverable->category === 'Deliverable') {
                             $photo_deliverables += $deliverable->price;
                         } else {
                             if ($deliverable->class === 'Video' && $deliverable->category === 'Service') {
                                 $video_services += $deliverable->price;
                             } else {
                                 if ($deliverable->class === 'Video' && $deliverable->category === 'Deliverable') {
                                     $video_deliverables += $deliverable->price;
                                 }
                             }
                         }
                     }
                 }
                 $resources = $this->event_user->get_by_event_id($event->id);
                 $event->team_leads = array();
                 $event->photographers = array();
                 $event->video_leads = array();
                 $event->videographers = array();
                 foreach ($resources as $resource) {
                     foreach ($resource as $key => $value) {
                         if ($key !== 'name' && $key !== 'phone_1' && $key !== 'type') {
                             unset($resource->{$key});
                         }
                     }
                     if ($resource->type === 'Team Lead') {
                         $event->team_leads[] = $resource;
                     } else {
                         if ($resource->type === 'Photographer') {
                             $event->photographers[] = $resource;
                         } else {
                             if ($resource->type === 'Video Lead') {
                                 $event->video_leads[] = $resource;
                             } else {
                                 if ($resource->type === 'Videographer') {
                                     $event->videographers[] = $resource;
                                 }
                             }
                         }
                     }
                 }
                 if (!empty($event->team_leads) || !empty($event->photographers)) {
                     $event->team_html = '<a class="team color-' . explode(' ', $this->session->setting['link_color']->value)[0] . '" style="cursor: pointer">View<span style="display: none">';
                     if (!empty($event->team_leads)) {
                         $event->team_html .= '<strong>Team Leads</strong><br>';
                         foreach ($event->team_leads as $team_lead) {
                             $event->team_html .= $team_lead->name . '<br>';
                         }
                     }
                     if (!empty($event->photographers)) {
                         $event->team_html .= '<strong>Photographers</strong><br>';
                         foreach ($event->photographers as $photographer) {
                             $event->team_html .= $photographer->name . '<br>';
                         }
                     }
                     $event->team_html .= '</span></a>';
                 } else {
                     $event->team_html = 'Unavailable';
                 }
                 $project->events[] = array(date("d/m/Y", strtotime($event->date)), $event->event_type, $event->venue, $event->shift, $event->event_status_html, $event->photoshoot_status_html, $event->team_html);
             }
             if (strpos($project->tax, '%') !== false) {
                 $tax = $project->tax * $project->cost / 100;
             } else {
                 $tax = $project->tax;
             }
             $project->cost += $tax;
             if (strpos($project->discount, '%') !== false) {
                 $discount = $project->discount * $data['project']->cost / 100;
             } else {
                 $discount = $project->discount;
             }
             $project->cost -= $discount;
             $project->albums_pending = $albums_total - $albums_ready;
             $project->expense_labels = array();
             $project->expense_data = array();
             if ($photo_services > 0) {
                 $project->expense_labels[] = 'Photo Services';
                 $project->expense_data[] = $photo_services;
             }
             if ($photo_deliverables > 0) {
                 $project->expense_labels[] = 'Photo Deliverables';
                 $project->expense_data[] = $photo_deliverables;
             }
             if ($video_services > 0) {
                 $project->expense_labels[] = 'Video Services';
                 $project->expense_data[] = $video_services;
             }
             if ($video_deliverables > 0) {
                 $project->expense_labels[] = 'Video Deliverables';
                 $project->expense_data[] = $video_deliverables;
             }
             $allowed_project_fields = array('id', 'name', 'advance', 'payment', 'cost', 'albums_pending', 'events', 'expense_labels', 'expense_data');
             foreach ($project as $key => $value) {
                 if (!in_array($key, $allowed_project_fields)) {
                     unset($project->{$key});
                 }
             }
         }
         $data['datatables'] = '';
         $data['modal'] = '';
         $data['moment'] = '';
         $data['chart'] = '';
         $data['view_name'] = 'dashboard_client';
     } else {
         $data['view_name'] = 'dashboard';
     }
     return $data;
 }