Last active
December 7, 2015 15:58
-
-
Save daTokenizer/baaf5bd23a203680eb17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def timezoneDiffFromGMT(lat, lon): | |
lon_degrees_per_timezone_hour = 360/24 | |
utc_centeral_lon_degrees = lon_degrees_per_timezone_hour * 12 | |
lon_degrees_from_utc = lon - utc_centeral_lon_degrees | |
return lon_degrees_from_utc / lon_degrees_per_timezone_hour | |
def isNight(lat, lon): | |
hour_at_location = time.gmtime().tm_hour + timezoneDiffFromGMT(lat, lon) | |
return not 5 < hour_at_location < 22 #set aprox day start and day end times as you like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment