f.lux has the amazing ability to change the color temperature of your screen based on the position of the sun in your current location.
To replicate this feature, you have three options:
- Allow users to toggle on/off - my recommendation due to total control and ease of use, but may require frequent adjustments.
- Have users manually set their position and sunrise-sunset times - more challenging for users.
- Implement auto detection.
If you opt for the latter, using APIs is essential. You can obtain the location via IP address (although it may not be entirely accurate). Yahoo offers an API that provides sunrise/sunset times.
For example, this query will give you the sunset time in Maui:
select astronomy.sunset from weather.forecast where woeid in (select woeid from geo.places(1) where text="maui, hi")
To adjust screen brightness and color dynamically, check out Fabian Schultz's solution on Stack Overflow.