Guest User

Untitled

a guest
Nov 15th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <?php
  2.  
  3. function sunIsUp(\DateTime $when, $lat, $lon): bool
  4. {
  5. $whenTimestamp = $when->getTimestamp();
  6.  
  7. [$sunriseTimestamp, $sunsetTimestamp] = array_map(function ($f) use ($whenTimestamp, $lat, $lon) {
  8. return $f($whenTimestamp, SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
  9. }, ['date_sunrise', 'date_sunset']);
  10.  
  11. return ($whenTimestamp > $sunriseTimestamp) && ($whenTimestamp < $sunsetTimestamp);
  12. }
Add Comment
Please, Sign In to add comment