public static function LiveWeather::checkDayNight in Live Weather 8.2
Same name and namespace in other branches
- 8 src/LiveWeather.php \Drupal\live_weather\LiveWeather::checkDayNight()
Check Day or Night.
Overrides LiveWeatherInterface::checkDayNight
File
- src/
LiveWeather.php, line 108 - Contains \Drupal\live_weather\LiveWeather.
Class
- LiveWeather
- Live weather.
Namespace
Drupal\live_weatherCode
public static function checkDayNight($date, $sunrise, $sunset) {
$position = Unicode::strpos($date, ":");
$tpb = Unicode::substr($date, $position - 2, 8);
$actual_time = strtotime($tpb);
$sunrise_time = strtotime($sunrise);
$sunset_time = strtotime($sunset);
if ($actual_time > $sunrise_time && $actual_time < $sunset_time) {
return 'd';
}
else {
return 'n';
}
return 'd';
}