RTC DS 3231 turn on in the morning and turn off in the evening

Good afternoon,
i have a DS-3231, and i have to turn on a Rele at sunrise and turn off it at sunset.
Well, my problem is that everyday sun goes up and down at different time, something like 1min later (or before, it depends by season) every 3 days.
i know on 21th june sunrise at 5.34, sunset at 20.23.
24th june sunrise at 5.36, sunset at 20.24
27th june 5.35, sunset at 20.23

how can i program arduino to calculate time sunset and sunrise of Today? if it calculates, i know what time to turn on and turn off my device.
something like:

1)void (loop)
check date and time
2)calculates what time to turn on and off
3)if we are in this time frame then turn on Rele, otherwise turn off.

what can i do? i have not idea from where to begin :frowning:
Any suggestion?

i reply to myself because after a research i ve found TimeLord so maybe i can use it. Does someone give me opinion about it?

For an approximation start adding 3 minutes a day from December 7 until June 21, then do the opposite until December 6. You can get the information from an online source every few days, put it in a table, etc. The calculations are readily available on line but are quite involved.
This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!

i reply to myself because after a research i ve found TimeLord so maybe i can use it.

Whatever it is, it won't do any worse than a DS3231. The DS3231 will do a great job of telling you the time and date but that is all. Following the advice in reply #2 would be a good idea only if you live on the same latitude and have winter solstice on December 6. The former is rather unlikely and the latter most unlikely. If this exercise is about daylight, you may find the best option is to use a photoelectric device and not bother calculating anything. This would then take into account local circumstances like cloud, fog, etc., which may have some bearing on the matter. The DS3231 may then be redundant.