An Arduino drives the switch-mode power supply, offering dimming thanks to PWM, and the ability to automatically switch the light on and off using an RTC chip with a battery backup. The sketch ...
[Runtimemicro] has the answer, at least if you are writing PWM code for the Arduino. Their free application lets you set a few parameters, visually see the results, and then generates code for you.