Day/Night algorithm

What's the algorithm you decided to use for this so that you e.g. can show moon icons for weather instead of sun icons?

Did you decide to use fixed time frames like 20 - 8 is night and 8 - 20 is day or does anyone have a more "smart" logic for this?