even with a valid location the sunrise/sunset time calculations can be buggy,
Really? I wrote a sunrise/sunset timer program for my "anti-burglar" presence lights, the algorithms are easily available on the web. Even the ancient Greeks managed to do that calculation.