Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function sunIsUp(\DateTime $when, $lat, $lon): bool
- {
- $whenTimestamp = $when->getTimestamp();
- [$sunriseTimestamp, $sunsetTimestamp] = array_map(function ($f) use ($whenTimestamp, $lat, $lon) {
- return $f($whenTimestamp, SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
- }, ['date_sunrise', 'date_sunset']);
- return ($whenTimestamp > $sunriseTimestamp) && ($whenTimestamp < $sunsetTimestamp);
- }
Add Comment
Please, Sign In to add comment