示例#1
0
文件: clock.php 项目: netbiel/core
if ($user && $user->latitude && $user->longitude) {
    $latitude = $user->latitude;
    $longitude = $user->longitude;
} else {
    $latitude = 60.1829;
    $longitude = 24.9549;
}
$sun = date_sun_info(time(), $latitude, $longitude);
$sunrise = __('Sun rises at :sunrise, sun sets at :sunset', array(':sunrise' => Date::format(Date::TIME, $sun['sunrise']), ':sunset' => Date::format(Date::TIME, $sun['sunset'])));
// Weather
if ($user && $user->city_name) {
    $location = $user->city_name;
} else {
    $location = 'Helsinki';
}
$weather = Weather::get_weather($location);
$today = $weather['wind'] . ', ' . $weather['humidity'];
$tomorrow = array();
$next = array();
$d = 0;
foreach ($weather['forecast'] as $day => $forecast) {
    $min = ($forecast['low'] > 0 ? '+' : '') . $forecast['low'] . '°';
    $max = ($forecast['high'] > 0 ? '+' : '') . $forecast['high'] . '°';
    switch ($d) {
        case 0:
            $today = __('Min: :min, Max: :max', array(':min' => $min, ':max' => $max)) . ', ' . $today;
            break;
        case 1:
            $tomorrow = $max . ' ' . HTML::chars($forecast['condition']);
            break;
        default: