Is there a natural (or algorithmic) way to switch from a light to a dark mode? [on hold]

I wrote a home dashboard which displays text in various fonts and colors. Some of the text is in labels (the temperatures below for example).

A fragment of the dashboard is below:

enter image description here

This is a light mode which is great for the day but too bright for the night. I would like to switch it automatically at sunset towards a dark mode.

Is there an algorithm which converts light mode colors to dark mode ones?

Right now I maintain two sets of colors but beside the fact that this is not practical when having a lot of independent components (each of them styled independently), there may be a more formalized way to transition between modes?