Updated the day/night cycle script

The script handling the day/night cycle has been updated, courtesy of
Ward.