Roughly speaking, it comes down to the fact that you must always have a light on between sunset and sunrise. The only condition is that you do not bother other cyclists or road users. You can read all the official rules in the Bike Lights Buyer’s Guide.